Re: Cleaner daemon managed by Launchd?
Re: Cleaner daemon managed by Launchd?
- Subject: Re: Cleaner daemon managed by Launchd?
- From: Gerd Knops <email@hidden>
- Date: Sat, 7 Mar 2009 17:36:00 -0600
On Mar 7, 2009, at 5:26 PM, Olivier Palliere wrote:
Hi All,
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.
I know this is maybe overkill, but would it be an option to have
some sort of watchdog managed by launchd that would do my cleanup if
necessary.
What I thought about is using Launchd to monitor a file (my app.pid
file in /var/run) and start my cleaner daemon to check every minute
or so that my app is running. If I detect the app is dead but the
pid file is still there, I do the cleanup and then remove the pid
file.
Is this an acceptable solution ? And can I mix WatchPaths with
StartInterval, that is, have the job start with WatchPaths, and then
run every 'StartInterval' until I am in the situation where my app
died, and the cleaner will do the job and stop the StartInterval
(this is also what I'd do if my app quits gracefully, to stop the
cleaner from kicking when my app is not running).
Unless we are talking huge amounts of data (GB), IMHO that would
probably cause more trouble (due to more complex install/deinstall)
than it is worth, especially as we are talking about the abnormal
termination case only. A much easier compromise might be to clean up
stale data on the next launch.
Gerd
_______________________________________________
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