From owner-freebsd-hackers@FreeBSD.ORG Sat Nov 27 21:35:42 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA8801065694 for ; Sat, 27 Nov 2010 21:35:42 +0000 (UTC) (envelope-from roam@ringlet.net) Received: from erengrad.hoster.bg (erengrad.hoster.bg [77.77.142.9]) by mx1.freebsd.org (Postfix) with ESMTP id 207788FC26 for ; Sat, 27 Nov 2010 21:35:41 +0000 (UTC) Received: from middenheim.hoster.bg (middenheim.hoster.bg [77.77.142.11]) by erengrad.hoster.bg (Postfix) with ESMTP id 96547DCD26 for ; Sat, 27 Nov 2010 23:08:24 +0200 (EET) Received: from straylight.ringlet.net (host41.office-vpn.int.hoster.bg [10.100.10.41]) (Authenticated sender: roam@hoster.bg) by mail.hoster.bg (Postfix) with ESMTP id 993415C3E6 for ; Sat, 27 Nov 2010 23:08:15 +0200 (EET) Received: from roam (uid 1000) (envelope-from roam@ringlet.net) id 416015 by straylight.ringlet.net (DragonFly Mail Agent) Sat, 27 Nov 2010 23:08:15 +0200 Date: Sat, 27 Nov 2010 23:08:15 +0200 From: Peter Pentchev To: Dirk-Willem van Gulik Message-ID: <20101127210815.GC3810@straylight.ringlet.net> Mail-Followup-To: Dirk-Willem van Gulik , "Carlos A. M. dos Santos" , FreeBSD-Hackers , Dimitry Andric , d@delphij.net References: <4CEEC3BD.3080204@delphij.net> <4CF13D7A.4060904@FreeBSD.org> <2096C74B-62C5-4841-B05D-A3C55E759291@webweaving.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: <2096C74B-62C5-4841-B05D-A3C55E759291@webweaving.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-MailScanner-ID: 993415C3E6.484BF X-hoster-MailScanner: Found to be clean X-hoster-MailScanner-SpamCheck: not spam, SpamAssassin (cached, score=0.001, required 10, autolearn=disabled, UNPARSEABLE_RELAY 0.00) X-hoster-MailScanner-From: roam@ringlet.net X-hoster-MailScanner-To: freebsd-hackers@freebsd.org X-Spam-Status: No Cc: "Carlos A. M. dos Santos" , FreeBSD-Hackers , Dimitry Andric , d@delphij.net Subject: Re: Is it possible to have file removed upon process exit? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Nov 2010 21:35:42 -0000 --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 27, 2010 at 08:16:54PM +0100, Dirk-Willem van Gulik wrote: >=20 > Op 27 nov 2010, om 20:07 heeft Carlos A. M. dos Santos het volgende gesch= reven: >=20 > > On Sat, Nov 27, 2010 at 3:18 PM, Dimitry Andric wrote: > >> On 2010-11-25 21:14, Xin LI wrote: > >>>=20 > >>> For certain applications it is sometimes desirable to (e.g. for unix > >>> domain sockets) have file removed when the process quit, regardless > >>> whether the process is quit cleanly. Is there a clean way to do this? > >>=20 > >> Maybe your process could be the child of a parent which cleans up > >> afterwards? (This is an analogy from real life. ;) >=20 > Another option, depending on the situation is to fopen()/open() the file = - and as soon as that is successfully done by all involved - have the creat= ing process delete it. Errr... didn't the original poster also write the following? :) (admittedly, in a part that the follow-uppers skipped) > >>> One pretty common way of having an i-node of a file removed when proc= ess > >>> exit is to unlink() it while holding a descriptor of the file. This > >>> approach, however, have a side effect that other processes would not = be > >>> able to access the file via its name. G'luck, Peter --=20 Peter Pentchev roam@space.bg roam@ringlet.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 You have, of course, just begun reading the sentence that you have just fin= ished reading. --huq684BweRXVnRxX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBCAAGBQJM8XMwAAoJEGUe77AlJ98TV80QAJTafcUMDkOZGQ8kp0vGD5QP YLWZUIkJA/k9/4a5/AxlFC6bdLYgYT85i/U4j1CxEybC9tJNJuoZOiyZO3uEarO/ 24RCDdm0nORQc1Yh1xJDe5RCVBhVmaAbTSikYPo7rYf1R8bkbRc5aYspJVyPmxy7 XZR4mbMu1bbzmmZpOcVaAhnqVhB/8HeCkWH+47BaQNBzToOkN9LxZO4uQ+CSxBOE aabkWIFXpYR+Re15Olsfy41VvOvI/igdAgsDFJfRMJSg3kbb9mdzgSVDfsVIcLTH HIRR0vaqZ8Irx8mxNzf53Ms6bC+KAqzKCj2tvnqBKkuAu1y9OJbS6haUbrTAqATO qUiHTw3vtbu4WIXCAp/jaJ1NnNDTlLBNB+CJcYX5EbUBBNWvKeYygeemmsbbdsZW Ir/xhZOVF4X+e7bRXdRiORAHY0SzsfLRjYo2iXiYgmH//cYeMsfh6Co3J653hNwS h80vpwgdJWkx8KKJdjBCQhCnRKZSZ0t39V4BnCCqGnBpp3SSl07eSgrS9YbdZtJ/ keP3r9JnNnH26OQQVohK138YmjZky8lfk4UmTA4I84rBezfrkQatdv9bm+ucGiTV wFkds6BWWz6ZG7vrPoIrRDjmIp99Et5kFzv9hsJRdT+nf+gEyulcSOcp2GrpmDKz raXGjeqrZm/qvt+rkFGe =uya7 -----END PGP SIGNATURE----- --huq684BweRXVnRxX--