[launchd-dev] Replacements for deprecated SMJobSubmit and SMJobRemove for plugins

Dave MacLachlan dmaclach at gmail.com
Wed Oct 19 07:23:53 PDT 2016


Change of subject so I don't threadjack, but related...

Is there a good way for a plugin to start up an xpc job? Before you say
"why isn't your plugin an xpc job", it's something I want to launch from a
XCTest bundle to monitor my test externally.

Cheers,
Dave

On Tue, Oct 18, 2016 at 10:26 AM, Joe Auricchio <jauricchio at apple.com>
wrote:

> 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
>
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> https://lists.macosforge.org/mailman/listinfo/launchd-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/launchd-dev/attachments/20161019/0701a802/attachment.html>


More information about the launchd-dev mailing list