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 <[email protected]> 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.

The libc call tmpfile(3) basically does just this. 

Also have a look at atexit(3) - though it is not called in messy sitations - 
the fork/waiting for a signal is propably about as robust as it gets. Another 
variation is something like 'open all the files/sockets you need, fork and have 
the parent delete them - while the child runs -then wait'.

Dw.

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[email protected]"

Reply via email to