[launchd-dev] Replacements for deprecated SMJobSubmit and SMJobRemove

Joe Auricchio jauricchio at apple.com
Tue Oct 18 10:26:25 PDT 2016


Hi Graham,

Please *do not* shell out to launchctl. It's better to keep using the deprecated SM functions than to run launchctl. Sorry, but replacements are not yet available.

There isn't presently API for a system-wide LaunchDaemon to open a Mach IPC or XPC connection to a LaunchAgent, which I'd guess is closer to what you'd really like to do? This would be a good enhancement request, please file one! Radars from developers are always good ammunition for trying to schedule our development time. (Coincidentally, now is a very good time for this particular API request.)

Another approach is for the LaunchAgents to add a LaunchEvent (man xpc_events) for a notifyd (man notify_post) notification. When the daemon wishes for an agent to start, it will post a notification; the LaunchEvent will start agents (in all the running graphical user sessions) in response to the notification; the agents will all check in with the daemon over MIG or XPC when their xpc_event handler fires; and the daemon will ask the appropriate agent to launch a process in the graphical user session. Combined with Pressured Exit aka idle-exit aka Sudden Termination, this would allow your agents to run only when they are needed without worrying about loading/removing their plists.

> On Oct 18, 2016, at 08:32, Graham Miln <graham.miln at gmail.com> wrote:
> 
> In macOS 10.12's ServiceManagement/ServiceManagement.h the following functions are marked as deprecated since macOS 10.10:
> 
> - SMJobSubmit
> - SMJobRemove
> - SMCopyAllJobDictionaries
> 
> The header mentions replacements will be provided by libxpc. Are replacements available or on the way?
> 
> I have a system wide daemon that would like to programmatically launch a process in a graphical user session. At the moment, our LaunchAgents managed helper process is always running. Ideally, it would be good to launch and exit the helper on-demand.
> 
> I believe this can now be done with `launchctl bootstrap|bootout gui/<uid>` on the command line. Should the daemon call out to the launchctl tool?
> 
> Kind regards,
> 
> Graham
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/launchd-dev



More information about the launchd-dev mailing list