[launchd-dev] Stopping and unloading an agent from root-privileged application

Quinn "The Eskimo!" eskimo1 at apple.com
Fri Jan 7 02:17:49 PST 2011


On 5 Jan 2011, at 17:30, James Bucanek wrote:

> Try this.
> 
> % sudo -u <username|#uid> launchctl stop my.agent
> % sudo -u <username|#uid> launchctl unload /Library/LaunchAgents/my.agent.plist

Have you actually tried this?  It /might/ work on 10.6, but I'm almost certain it won't work on 10.5 because launchctl looks up the launchd to talk to via its Mach bootstrap namespace, and sudo doesn't switch namespace.

On 4 Jan 2011, at 19:57, eveningnick eveningnick wrote:

> How could i stop an agent from root-privileged application?

There's no good solution to this.  I generally recommend that you use IPC between your daemon and agents to tell the agents to stop.

What's the high-level goal here?  Uninstall?

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




More information about the launchd-dev mailing list