launchd hiccups

Martin Dittus · 2005-08-13 · osx, tools · write a comment

I'm currently testing the Safari CookieFilter script and have stumbled upon strange launchd behavior that I can't explain nor find a way to fix. Essentially launchd seems to be fairly liberal in how it interprets LaunchAgent triggers, and regularly seems to choke under conditions that I can't reproduce.

The current release version of the CookieFilter LaunchAgent is designed to trigger the script every time there are changes to your Cookies.plist storage. But after running the LaunchAgent for a couple of days I found that it seems to stop responding to changes of this file. With some testing I found that this seems to happen after somewhere between 20-40 hours, but the reason is unclear.

My current assumption is that either there is an error or missing statement in de.dekstop.CookieFilter.plist that I can't find, or that this is a launchd bug. I've currently given up finding the cause, and decided to try another approach: to launch CookieFilter periodically using the StartInterval directive (I set it to trigger every 60 minutes).

But even this is unreliable: now the CookieFilter script is started roughly every hour, but also frequently at seemingly arbitrary points in time in between the hour. Looking at the logfile I can see that is has been triggered at least 20 times in the last hour.

So the current conclusion seems to be that triggering a LaunchAgent periodically instead of via a WatchPaths entry seems more stable, but there is no guarantee that your StartInterval setting is adhered to.

The other conclusion could be that I simply have to reboot the system after all the launchd fiddling to bring it back to a clean state (In the beginning of testing I've used the same LaunchAgent Label for LaunchAgents with different behavior, which could have triggered launchd bugs); but currently I'm reluctant to admit to that possibility. Update: rebooting didn't help.

Watch this blog for further updates.


Next article:

Previous article:

Recent articles:

Comments

Comments are closed. You can contact me instead.