Launchd never stops my HelperTool
Launchd never stops my HelperTool
- Subject: Launchd never stops my HelperTool
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sat, 05 Dec 2015 13:11:03 +0700
I have a HelperTool (installed via SMJobBless).
The HelperTool does:
NSXPCListener *listener = [[NSXPCListener alloc] initWithMachServiceName: bundleId ];
listener.delegate = myNSXPCListenerDelegate;
[listener resume];
NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop];
[ currentRunLoop run ];
“Daemons and Services Programming Guide” → “Creating XPC Services” → "Understanding the Structure and Behavior" says:
"XPC services are managed by launchd, which launches them on demand, restarts them if they crash,
and terminates them (by sending SIGKILL) when they are idle.”
“launches them on demand” works fine.
But: “terminates them when they are idle” never happens.
What to do:
(a) Just trust launchd; it probably has decided that relaunching is more costly than keeping the process running.
(b) launchd has no idea that the HelperTool is idle, because the RunLoop is still running. The HelperTool should quit the RunLoop when there are no more active NSXPCConnections.
If (b) what should the HelperTool do if it decides there is no more work to do:
(b1) just exit(EXIT_SUCCESS)
(b2) [listener invalidate], followed by exit(EXIT_SUCCESS).
Gerriet.
_______________________________________________
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