Bug in launchd? Agent sometimes just stops working until unloaded/reloaded
[Sorry... posted 3 days ago on darwin-userlevel@lists.apple.com before I knew about this list] I've seen several times in the last few months a randomly-occuring bad state in launchd wherein a LaunchAgent will fail silently; i.e. not run its program when triggered. Unloading and reloading the agent immediately knocks it out of this bad state. My app installs a launchd agent with a "WatchPaths" trigger. During a testing session in which the trigger is exercised several times, sometimes, if I change the watched path once again (after waiting the required ThrottleInterval), Finder indicates a new modification date, but launchd doesn't run my program nor log anything to console. Repeatable. While it is in this broken state, if I tell launchctl to 'list' my agent, it appears to be loaded. If I copy the ProgramArguments from the listing and run the target program in Terminal, it executes OK. Unload/reloading the agent like this: Jerrys-Mac-Mini:~ jk$ launchctl unload /Users/jk/Library/LaunchAgents/com.sheepsystems.BookMacster.10015DE4-45B0-4019-BAC7-A07229C22C07.000.001.plist Jerrys-Mac-Mini:~ jk$ launchctl load /Users/jk/Library/LaunchAgents/com.sheepsystems.BookMacster.10015DE4-45B0-4019-BAC7-A07229C22C07.000.001.plist fixes the problem immediately; the agent starts responding as expected to WatchPaths changes once again. The output from 'launchctl list MyAgent' is exactly the same before or after the unload/reload fix: Jerrys-Mac-Mini:~ jk$ launchctl list com.sheepsystems.BookMacster.10015DE4-45B0-4019-BAC7-A07229C22C07.000.001 { "Label" = "com.sheepsystems.BookMacster.10015DE4-45B0-4019-BAC7-A07229C22C07.000.001"; "LimitLoadToSessionType" = "Background"; "OnDemand" = true; "LastExitStatus" = 0; "TimeOut" = 60; "ProgramArguments" = ( "/Users/jk/Documents/Programming/Builds/Debug/BookMacster.app/Contents/Helpers/BookMacster-Worker"; "10015DE4-45B0-4019-BAC7-A07229C22C07"; "0"; ); }; The LimitLoadToSessionType key is mysterious. Besides the fact that I don't comprehend its documentation, this key is not in my plist file, and I do not believe that my code appends a -S option when invoking launchctl to load the job (which it does via NSTask). I was wondering if maybe my rebuilding of the program (i.e. rewriting the executable) was causing the problem. But it does not, at least not reproducibly. Has anyone ever noticed this bug? Can anyone suggest any conditions which might make it reproducible? Any weak spots where I should "push"? Thanks, Jerry Krinock Here's the agent's plist file:
participants (1)
-
Jerry Krinock