Re: How to make a LaunchAgent
Re: How to make a LaunchAgent
- Subject: Re: How to make a LaunchAgent
- From: Roland King <email@hidden>
- Date: Mon, 11 Aug 2014 18:20:54 +0800
> On 11 Aug 2014, at 6:07 pm, Gerriet M. Denkmann <email@hidden> wrote:
>
> I have a Xpc Helper, which is local to my App (that is only my App can talk to it) which works fine.
>
> Now I want to convert this Xpc Helper into a LaunchAgent.
>
> I guess I have to start it via SMJobSubmit().
> But when I do this with the existing Helper, it crashes, gets restarted, crashes again, etc. ad infinitum.
>
> So the Helper must be modified as well. But how?
>
> And is this the right way to start it?
>
> let mach = [ "de.mdenkmann.Xpc-Exchange" : true ]
> let args = [ "/private/tmp/Xpc Exchange.xpc/Contents/MacOS/Xpc Exchange" ]
> let job = [ "Label" : "de.mdenkmann.Xpc-Exchange",
> "LimitLoadToSessionType" : "Background",
> "MachServices" : mach,
> "StandardErrorPath" : "/tmp/Xpc Exchange.log",
> "ProgramArguments" : args
> ]
> var outError : Unmanaged<CFError>?
> var auth : Authorization?
> let ok = SMJobSubmit( kSMDomainUserLaunchd, job, auth, &outError )
> ok = true, but then: crash with: "xpc_main() was probably called from a process that is not an XPC service bundle."
>
> Gerriet.
>
>
> P.S.
>
> SMJobSubmit is deprecated in 10.10. But the documentation mentions no replacement.
> What to use instead?
You’re not supposed to start it - launchd/XPC services is supposed to start it for you. You’re supposed to register it as a LaunchAgent/Daemon, creating the launchd.plist file and when you need the service, it starts and when you don’t, it’s stopped again. I keep reading this is all part of the security of XPC, only the system can kick one off.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden