[launchd-dev] Facing problem with launch daemon on logout

Quinn "The Eskimo!" eskimo1 at apple.com
Wed May 9 04:27:55 PDT 2012


On 8 May 2012, at 08:07, Nandini Vijayashankar wrote:

> If i restart the computer and login, my daemon is running.
> After this if i logout and login again, daemon is exited with error code 143
>  
> If i explicitly load the job, logout and login, daemon is running.
>  
> Problem is when the system is restarted and I logout and login.

It's likely that your daemon is connecting to the window server, and thus killed when the window server dies on logout.  Do the following:

$ otool -L /path/to/your/daemon

and check that all the frameworks you use are daemon safe [1].

Also, when you explicitly load the job, make sure you use "sudo".  Without that your daemon ends up loading in the per-user context, which generally isn't what you want.

Share and Enjoy 
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

[1] Per the definition in Technote 2083 "Daemons and Agents".

<https://developer.apple.com/library/mac/#technotes/tn2083/_index.html>



More information about the launchd-dev mailing list