Is it possible to have file removed upon process exit?
Peter Pentchev
roam at ringlet.net
Sat Nov 27 21:35:42 UTC 2010
On Sat, Nov 27, 2010 at 08:16:54PM +0100, Dirk-Willem van Gulik wrote:
>
> Op 27 nov 2010, om 20:07 heeft Carlos A. M. dos Santos het volgende geschreven:
>
> > On Sat, Nov 27, 2010 at 3:18 PM, Dimitry Andric <dim at freebsd.org> wrote:
> >> On 2010-11-25 21:14, Xin LI wrote:
> >>>
> >>> 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?
> >>
> >> Maybe your process could be the child of a parent which cleans up
> >> afterwards? (This is an analogy from real life. ;)
>
> 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 creating 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 process
> >>> 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
--
Peter Pentchev roam at space.bg roam at ringlet.net roam at 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 finished reading.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20101127/b4a70fe6/attachment.pgp
More information about the freebsd-hackers
mailing list