From owner-freebsd-hackers Wed Dec 18 17:57:40 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id RAA22751 for hackers-outgoing; Wed, 18 Dec 1996 17:57:40 -0800 (PST) Received: from dyson.iquest.net (dyson.iquest.net [198.70.144.127]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id RAA22746 for ; Wed, 18 Dec 1996 17:57:37 -0800 (PST) Received: (from root@localhost) by dyson.iquest.net (8.8.2/8.6.9) id UAA03663; Wed, 18 Dec 1996 20:57:25 -0500 (EST) From: "John S. Dyson" Message-Id: <199612190157.UAA03663@dyson.iquest.net> Subject: Re: mmap pain To: james@wgold.demon.co.uk (James Mansion) Date: Wed, 18 Dec 1996 20:57:23 -0500 (EST) Cc: hackers@FreeBSD.ORG In-Reply-To: <32B7E11E.22@wgold.demon.co.uk> from "James Mansion" at Dec 18, 96 12:18:38 pm Reply-To: dyson@FreeBSD.ORG X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > However, locks aren't inherited over a fork, so maybe the memory > is still mapped into some child process and might be used. > > It is just about feasible to require a child to reapply new locks > after the fork and for the parent to wait for it to do so, but > really I'd like to bury this in a library. > > Is there any (preferably generic) way to tell whether a file > has no (other) open descriptors attached to it and can be unlinked? > Anytime a program has a file mapped, it is kind-of equiv to the file being open. If you unlink a file that is mapped or open, you will immediately remove the directory entry, but the file will remain until the last process closes or unmaps the file. You unmap or close a file either by an explicit action or by the program exiting. It is also possible that a new reference can be gained by a process forking even after a file directory entry has been unlinked. John