[launchd-dev] (re)configure a launchd created UNIX domain socket after Fast User Switching (on El Capitan)

Quinn "The Eskimo!" eskimo1 at apple.com
Tue Mar 1 04:27:44 PST 2016


On 1 Mar 2016, at 10:44, Ludovic Rousseau <ludovic.rousseau at gmail.com> wrote:

> So I need a way to communicate from a process running as _tokend to a process with access to the graphical interface, a process started as the logged in user.

Do you care whether this GUI process is running all the time?  If not, you can just create a launchd agent and have it connect to your daemon.  When the daemon needs help, it can send a message to the appropriate connected agent (or send a message to /all/ the connected agents).

If you want the agents to /not/ be running all the time you can configure the agents to listen for a Darwin notification (see <x-man-page://3/notify> and <x-man-page://3/xpc_events>).  The daemon can then post that notification when it needs help.  This will launch the agents, and they can then connect to the daemon as above.

Regardless, you can use XPC (or the higher-level NSXPCConnection) to communicate between your daemon and agents.  An launchd daemon can advertise an XPC service via a MachServices property in the launchd property list.

Share and Enjoy
--
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