On Sat, Mar 7, 2009 at 8:30 PM, Ken Thomases <k...@codeweavers.com> wrote: > On Mar 7, 2009, at 5:26 PM, Olivier Palliere wrote: > >> I am working on an application that once started, sets up some temporary >> files and so. I didn't think of it at first, but I had the case where a >> friend force quitted the application, and I was left with the app not >> running, and still my temporary things hanging around. Ultimately, this is >> ok, as a reboot will clear /tmp, but ideally, I'd like to clear it up as >> soon as possible. > > Do your temp files really need to remain listed in the file system? You can > open/create them and then unlink them. Your file descriptor (or > NSFileHandle) will remain valid and will be able to access and manipulate > the file data, but the file won't be listed in the file system. When your > process exits (cleanly or otherwise), the kernel will make sure all of your > file descriptors are closed. In this case, because there are no more links > to the file, the closing of the last file descriptor to it will cause it to > be deleted.
And if they *really* do need to have a directory entry, your best bet is probably to spawn a little subprocess when you create the files that just sits and waits for its parent to die. Once the parent disappears for any reason, it can delete the files. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com