From owner-freebsd-hackers@FreeBSD.ORG Sat Nov 27 16:42:29 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 5940E106566B for ; Sat, 27 Nov 2010 16:42:29 +0000 (UTC) (envelope-from unixmania@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 11AF58FC17 for ; Sat, 27 Nov 2010 16:42:28 +0000 (UTC) Received: by qyk7 with SMTP id 7so3053882qyk.13 for ; Sat, 27 Nov 2010 08:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=OYyJ6edoYTWkecSFjo9LGa+KMJdV4K5rXba5IObXYfs=; b=IQcl7QSL+obtI/YPWPB+t+rouIAlHV5vCHs/jJ+vz40hEQH7AEEd5h5y0iOSs/Q0Vj d2qbN7TBFp/L6pscaIsLRXqTLxJ8pks+c8VhLMFenlxmzp/6WP+GM2OTUmUyzx3CAXVG ytDAs/QzGLZ6yL3K5IcJZFw63ud/I8D9Avvlc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=pMH9juEIqf+b0A6kJ5y9xfhhUDm7C1L/sTvd6kb914P6kHIjjfLTMxEOSujmt/pc9M RlJGXydhokVj0jcUV0bjW9McMhIqaYrAVl8sKieAZXv4xdJ347xXDzjAKr+CjPWtnokO pEweMoeEP3i/O+qpMwLQZ8rpGNcsbq0wsqBOw= MIME-Version: 1.0 Received: by 10.229.251.1 with SMTP id mq1mr3083037qcb.22.1290876148214; Sat, 27 Nov 2010 08:42:28 -0800 (PST) Received: by 10.229.37.9 with HTTP; Sat, 27 Nov 2010 08:42:28 -0800 (PST) In-Reply-To: <4CEEC3BD.3080204@delphij.net> References: <4CEEC3BD.3080204@delphij.net> Date: Sat, 27 Nov 2010 14:42:28 -0200 Message-ID: From: "Carlos A. M. dos Santos" To: d@delphij.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD-Hackers 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 16:42:29 -0000 On Thu, Nov 25, 2010 at 6:14 PM, Xin LI wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Hi, > > One pretty common way of having an i-node of a file removed when process > exit is to unlink() it while holding a descriptor of the file. =A0This > approach, however, have a side effect that other processes would not be > able to access the file via its name. > > 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. =A0Is there a clean way to do this? Did you try to use atexit(3) to register a deletion function?