• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cleaner daemon managed by Launchd?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cleaner daemon managed by Launchd?


  • Subject: Re: Cleaner daemon managed by Launchd?
  • From: Olivier Palliere <email@hidden>
  • Date: Sun, 08 Mar 2009 11:39:43 +0100



On Mar 8, 2009, at 5:38 AM, Michael Ash wrote:

On Sat, Mar 7, 2009 at 8:30 PM, Ken Thomases <email@hidden> 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.

Thanks a lot for your insight (both of you)!

This is basically what I did, except that currently my subprocess is not daemon capable, as I initially wanted to get that code handled by launchd which states *very* clearly that you should not fork or so.

Now it seems the requirements are shifting and I might have, over time (but not before another release), to also add a *deny* rule in ipfw when my code is running. In that case, if the app dies, then I have a bigger problem than just files hanging around ;-) but I'll think about this when the time comes.

Many thanks again for the help,
Olivier./.




Mike
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Cleaner daemon managed by Launchd? (From: Olivier Palliere <email@hidden>)
 >Re: Cleaner daemon managed by Launchd? (From: Ken Thomases <email@hidden>)
 >Re: Cleaner daemon managed by Launchd? (From: Michael Ash <email@hidden>)

  • Prev by Date: How to create a color catalog
  • Next by Date: Re: NSDrawNinePartImage draws slowly in CALayer
  • Previous by thread: Re: Cleaner daemon managed by Launchd?
  • Next by thread: NSArrayController -- will change selection?
  • Index(es):
    • Date
    • Thread