[launchd-dev] Disabling of launchd job if program is missing

Damien Sorresso dsorresso at apple.com
Tue Jul 6 10:57:40 PDT 2010


On Jul 6, 2010, at 2:29 AM, Vera Tkachenko wrote:
> Hello,
> 
> in my program I use quite a simple launchd jobs to perform some tasks. This job is configured to run some tool when certain conditions are met. All works fine except one case. When user deletes this tool (e.g. after incorrect uninstall of program), then launchd fails to find tool and therefore fails to run my job.
> 
> The following error is logged:
> 25/04/2010 23:26:11	com.apple.launchd.peruser.501[224] (<job label>[89736]) posix_spawn(<path to tool>, ...): No such file or directory

You should provide the user with an uninstaller so as to minimize the chances of screwing up the uninstall.

> The problem is that after this launchd keep trying to run this job. Why it just don't disable this job?

launchd doesn't know that the needed resource won't come online in the future, so it keeps trying. We used to automatically disable jobs if they failed to run a certain number of times. This didn't really help anyone and in fact made life harder if your binary lived on a network volume that didn't get mounted right away.

Basically, launchd expects you to have your ducks in a row and will patiently wait for you to get them there.

> If this is desired behavior, is it possible to configure it somehow to disable job if it's tool is missing? This is not just my software problem. Lots of other programs have such issues. 


If this is a concern for you, I'd suggest using a trampoline program. But it's worth finding out just how many of your customers run into this problem and whether you can expose the correct uninstall procedure in an easy-to-discover manner.
-- 
Damien Sorresso
BSD Engineering
Apple Inc.



More information about the launchd-dev mailing list