From owner-freebsd-questions Thu Oct 14 9:58: 1 1999 Delivered-To: freebsd-questions@freebsd.org Received: from gaia.gutierrez.com (gaia.gutierrez.com [206.105.100.5]) by hub.freebsd.org (Postfix) with ESMTP id 2F5E515032 for ; Thu, 14 Oct 1999 09:57:47 -0700 (PDT) (envelope-from carlos@gutierrez.com) Received: from localhost (carlos@localhost) by gaia.gutierrez.com (8.9.3/8.9.3) with ESMTP id MAA15665; Thu, 14 Oct 1999 12:57:40 -0400 (AST) Date: Thu, 14 Oct 1999 12:57:40 -0400 (AST) From: "Carlos M. Gutierrez" To: bschwart@bbn.com Cc: freebsd-questions@FreeBSD.ORG Subject: Re: mmap and MAP_INHERIT In-Reply-To: <38060073.4FD0443B@echo.bbn.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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