[launchd-dev] launchctl unload not working

James Bucanek subscriber at gloaming.com
Thu Nov 29 07:51:47 PST 2007


Kevin Van Vechten <mailto:kvv at apple.com> wrote (Wednesday, 
November 28, 2007 12:08 AM -0800):

>I recommend reading the "Daemonomicon" <http://developer.apple.com/technotes/tn2005/tn2083.html#SECDAEMONOMICON>.

Been there, read that. (This is the one technote I keep on my desktop.)

>Short summary pertinent to your symptoms:
>
>- Root (uid 0) launchd loads jobs from LaunchDameons directories.  Use `sudo launchctl` to communicate with it.

Exactly. Since this is a daemon installed in 
/Library/LaunchDaemons I was forking launchctl when running as 
root. But that's when all the trouble started. :(

>- Per-user (uid 501) launchd loads jobs from LaunchAgents directories.  Use `launchctl` to communicate with it.

This isn't an agent.

>- Per-user launchd ignores the UserName key because it does not have the privilege to execute as any other user than the current user.
>- Per-user mach bootstrap is a sub-bootstrap of the root mach bootstrap: agents can lookup daemons, but daemons cannot lookup agents.

I'll try to clean out my system (each instance of launchd seems 
to have its own, persistent, history of what's been loaded and 
unloaded) and run my tests again verifying that each execution 
of launchctl occurs when running as root. From your notes, and 
reading technote 2083, it appears that I was doing (or I 
*thought* I was doing) exactly what I I should have been doing: 
Copy the .plist file to /Library/LaunchDaemons, then invoke 
'launchctl load ...' as root to install the daemon and 
'launchctl unload ...' to uninstall the daemon.

James
-- 
James Bucanek



More information about the launchd-dev mailing list