Re: Launchd, AbandonProcessGroup, system() vs fork/exec
Re: Launchd, AbandonProcessGroup, system() vs fork/exec
- Subject: Re: Launchd, AbandonProcessGroup, system() vs fork/exec
- From: Stéphane Glondu <email@hidden>
- Date: Wed, 02 Nov 2011 17:16:57 +0100
On 11/02/2011 05:08 PM, Jason Coco wrote:
> I'm assuming that your main program exits relatively quickly after calling system(3) or execl(3). You simply *can't* do this when using launchd. The reason it appears to work in the first case is that system(3) actually blocks until the new process exits. This keeps your process alive during the entire life of the child, which is what launchd expects and wants, making it appear to work correctly (although none of your subsequent instructions get processed until after the system(3) call returns, so you're not actually doing any work in parallel). With exec(3), your process probably returns before the child, which launchd isn't going to be very happy with. Depending on what you're doing, it may just be best to keep your main process around until all its children are finished, and then exit cleanly after reaping them.
Or maybe you can just avoid forking and waiting for the child, and call
directly exec() if the caller really has nothing to do after the callee
returns...
Cheers,
--
Stéphane
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden