<div dir="ltr">Change of subject so I don't threadjack, but related...<div><br></div><div>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.<div><br></div><div>Cheers,</div><div>Dave<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 18, 2016 at 10:26 AM, Joe Auricchio <span dir="ltr"><<a href="mailto:jauricchio@apple.com" target="_blank">jauricchio@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Graham,<br>
<br>
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.<br>
<br>
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.)<br>
<br>
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.<br>
<div><div class="h5"><br>
> On Oct 18, 2016, at 08:32, Graham Miln <<a href="mailto:graham.miln@gmail.com">graham.miln@gmail.com</a>> wrote:<br>
><br>
> In macOS 10.12's ServiceManagement/<wbr>ServiceManagement.h the following functions are marked as deprecated since macOS 10.10:<br>
><br>
> - SMJobSubmit<br>
> - SMJobRemove<br>
> - SMCopyAllJobDictionaries<br>
><br>
> The header mentions replacements will be provided by libxpc. Are replacements available or on the way?<br>
><br>
> 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.<br>
><br>
> 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?<br>
><br>
> Kind regards,<br>
><br>
> Graham<br>
</div></div>> ______________________________<wbr>_________________<br>
> launchd-dev mailing list<br>
> <a href="mailto:launchd-dev@lists.macosforge.org">launchd-dev@lists.macosforge.<wbr>org</a><br>
> <a href="https://lists.macosforge.org/mailman/listinfo/launchd-dev" rel="noreferrer" target="_blank">https://lists.macosforge.org/<wbr>mailman/listinfo/launchd-dev</a><br>
<br>
______________________________<wbr>_________________<br>
launchd-dev mailing list<br>
<a href="mailto:launchd-dev@lists.macosforge.org">launchd-dev@lists.macosforge.<wbr>org</a><br>
<a href="https://lists.macosforge.org/mailman/listinfo/launchd-dev" rel="noreferrer" target="_blank">https://lists.macosforge.org/<wbr>mailman/listinfo/launchd-dev</a><br>
</blockquote></div><br></div></div></div></div></div>