[launchd-dev] Starting Agents in specific GUI sessions

Jerry Krinock jerry at ieee.org
Fri Aug 16 09:17:40 PDT 2013


On 2013 Aug 16, at 08:33, NuSkooler <nuskooler at gmail.com> wrote:

> … daemon … occasionally needs to display UI to users … more than just notifications

I would say that you should write a little app (.app) to do that, and your daemon should launch it as needed.  If this is for Mac OS X 10.7 or later, you should consider XPC.  Someone who knows more about XPC than I do please correct me and elaborate.

> there are times such as in our update process that we need to stop all agents -> update them -> restart them

In other words, you need to do in a program what a sysadmin can do "manually" using the launchctl(1) command-line tool.  I have some old code in a public repository at github.com which has methods which do this brute force, by invoking launchctl via NSTask.  But before you do something like that, I vaguely recall reading somewhere that there may now be proper API for this.  But I can't find any reference to it.

Does anyone know of such an API in Mac OS X, or was I just dreaming?

Jerry

P.S.  You didn't mention sandboxing.  I think the install/update/start/stop LaunchAgents stuff is unlikely to be allowed if you're sandboxed.



More information about the launchd-dev mailing list