Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Oct 1999 12:57:40 -0400 (AST)
From:      "Carlos M. Gutierrez" <carlos@gutierrez.com>
To:        bschwart@bbn.com
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: mmap and MAP_INHERIT
Message-ID:  <Pine.BSI.4.05L.9910141247050.15416-100000@gaia.gutierrez.com>
In-Reply-To: <38060073.4FD0443B@echo.bbn.com>

next in thread | previous in thread | raw e-mail | index | archive | help

If it is a forked child, use MAP_SHARED. Call mmap before forking the
child... You also need to open the file and get the file descriptor before
calling mmap.

My call looks something like this:

 ptr = (char*) mmap(0, sizeoffile, PROT_READ, MAP_SHARED, fd, 0);

If you are execve'ing a program, then I suppose then you would use
MAP_INHERIT, but I haven't used this yet in my programs.

Carlos

On Thu, 14 Oct 1999, Bev Schwartz wrote:

> The man page for mmap describes a parameter MAP_INHERIT as follows:
> 	Permit regions to be inherited across execve(2) system calls.
> 
> I would like a fork'ed and exec'ed child to be able to access mapped memory
> that the parent set up, but I have not yet figured out how to make this
> work.
> 
> Anyone have suggestions, or better, a piece of working code that does this?
> 
> -Bev
> 
> -- 
>  #   #           Bev Schwartz              email: bschwart@bbn.com
>  ### ### ###     BBN Technologies          voice: 617-873-2453
>  # # # # # #     10 Moulton Street           fax: 617-873-6091
>  ### ### # #     Cambridge, MA 02138      office: 6/503 Mailstop 6/5C
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
> 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSI.4.05L.9910141247050.15416-100000>