Cleaner daemon managed by Launchd?
Cleaner daemon managed by Launchd?
- Subject: Cleaner daemon managed by Launchd?
- From: Olivier Palliere <email@hidden>
- Date: Sun, 08 Mar 2009 00:26:15 +0100
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).
Many thanks for your input,
Oli./.
_______________________________________________
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