From owner-freebsd-hackers Wed Dec 18 14:57:23 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id OAA04500 for hackers-outgoing; Wed, 18 Dec 1996 14:57:23 -0800 (PST) Received: from wgold.demon.co.uk (wgold.demon.co.uk [158.152.96.124]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id OAA04488 for ; Wed, 18 Dec 1996 14:57:18 -0800 (PST) Received: from [127.0.0.1] by wgold.demon.co.uk (NTMail 3.01.03) id wa000984; Wed, 18 Dec 1996 12:18:38 +0000 Message-ID: <32B7E11E.22@wgold.demon.co.uk> Date: Wed, 18 Dec 1996 12:18:38 +0000 From: James Mansion Organization: Westongold Ltd X-Mailer: Mozilla 3.0Gold (WinNT; I) MIME-Version: 1.0 To: hackers@freebsd.org Subject: mmap pain Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Info: Westongold Ltd: +44 1992 620025 www.westongold.com Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk I have a 'well known' shared memory area that is in the file system and mapped using mmap. It is dynamically created if necessary. I'd like to tidy it up, too. I can quite easily detect if a process has opened it by placing locks at hashed offsets in the file and checking to see if there are any locks in place. If not, then it should be safe to delete since I'm the last user. 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? James