[launchd-dev] Starting Agents in specific GUI sessions

NuSkooler nuskooler at gmail.com
Wed Aug 21 09:21:39 PDT 2013


Thank you again for all of your replies!

My current plan for OS X is to register my Agent with launchd to start at
user login (e.g. once per session) and use the clean exit code members of
the plist to keep it alive unless explicitly shut down cleanly (In other
words, keep it alive in case it crashes; else let it exit)

As I mentioned, on Windows we do spawn some "Agent" processes on demand in
user(s) session spaces. I may be able to modify this slightly, but if not,
from what I understand this is the appropriate approach:

daemon (launchd spawned as daemon) -> {IPC} -> agent_shim (launchd spawned
as login agent) -> execute real_agent (will be in users context)

This seems like a fair approach, if needed.

As far as questions about "asuser": In 10.8 at least, this will create a
process as the user, but in the context of the launchd that launchctl
talked to. The rules for this can be seen in the launchctl code, but
basically if EUID or UID are root, use the root/system launchd, else use
the current users's launchd. TL;DR, it doesn't allow you to change the
session the process is launched in, only the user it's run as.

Bryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-dev/attachments/20130821/71f385ef/attachment.html>


More information about the launchd-dev mailing list