Re: Launchd, AbandonProcessGroup, system() vs fork/exec
Re: Launchd, AbandonProcessGroup, system() vs fork/exec
- Subject: Re: Launchd, AbandonProcessGroup, system() vs fork/exec
- From: Tilghman Lesher <email@hidden>
- Date: Wed, 02 Nov 2011 16:47:21 -0500
On Wed, Nov 2, 2011 at 1:57 PM, Jason Coco <email@hidden> wrote:
> I believe it's designed to allow short-lived processes to complete whatever
> service they're providing if the parent dies unexpectedly, not for when the
> parent exits and basically says "okay, I'm all done," like in your case. An
> example might be an http daemon that uses processes to service individual
> requests. If the daemon process dies, the child processes are given a chance
> to complete their service and exit before being killed and reaped by
> launchd.
If the OP is wanting to do things in parallel, however, he might try to call
waitpid() in the parent before exiting. Another possible solution might be
to sleep(1) before exiting in the parent. It might be enough to trick launchd
into thinking that the process wasn't simply doing the "moral equivalent" of
daemon(3) (see the launchd.plist manpage).
And finally, a third solution might be to call setsid() in the child
prior to the
execl(). This will ensure the child has a different process group ID, thus
avoiding the issue with launchd killing processes with the same process
group ID. One caveat: ensure the parent sleep()s before exit()ing, or the
exit of the parent may occur before the child has a chance to setsid().
_______________________________________________
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
References: | |
| >Launchd, AbandonProcessGroup, system() vs fork/exec (From: Todd Heberlein <email@hidden>) |
| >Re: Launchd, AbandonProcessGroup, system() vs fork/exec (From: Jason Coco <email@hidden>) |
| >Re: Launchd, AbandonProcessGroup, system() vs fork/exec (From: Stéphane Glondu <email@hidden>) |
| >Re: Launchd, AbandonProcessGroup, system() vs fork/exec (From: Todd Heberlein <email@hidden>) |
| >Re: Launchd, AbandonProcessGroup, system() vs fork/exec (From: Jason Coco <email@hidden>) |
- Prev by Date:
Re: Launchd, AbandonProcessGroup, system() vs fork/exec
- Next by Date:
Creating a single package for 10.4 ,10.5 ,10.6 ,10.7
- Previous by thread:
Re: Launchd, AbandonProcessGroup, system() vs fork/exec
- Next by thread:
Creating a single package for 10.4 ,10.5 ,10.6 ,10.7
- Index(es):