Re: Launchd, AbandonProcessGroup, system() vs fork/exec
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20111010 Icedove/3.1.15 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Stéphane Glondu