Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: waitid() function replacement




On 4/5/06, Eric Gouriou <email@hidden> wrote:

  The PID cannot be reused until your parent process gives a chance
to the OS to reap
the zombie.

  On most Unix-derived OSes you should be able to set your SIGCHLD
handling in such
a way that the children will remain zombies until wait() or waitpid()
is used.
This removes the race condition you are concerned about.

Thanks for your suggestion.

To further clarify, what I need to be able to do is find out if the processes my program spawns has terminated (without cleaning them up).  After I know the process is done, I need to signal the rest of the process group to clear out any processes it may have spawned (that haven't changed to a new process group).  I can't use waitpid() to find out if the process has quit and then signal the process group.

Playing with the signal handlers to act on SIGCHLD could be fairly difficult (but not impossible), as my program spawns these processes from different threads, and there is no guarantee which of my threads will receive the signal.  I'll look at this to see if I can come up with anything.

The only somewhat easy alternative (ugly hack) I could come up with is to spawn a second process that I don't care about, and place it in the same process group.  This process could be  blocked on input, permanently sleeping, or doing something else that uses little resources.  After waiting on the process I care about, the entire group (which will still be active because of this second useless process) can then be safely signalled.

Any other ideas or suggestions would be appreciated.

Thanks.
-Kevin-
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden

References: 
 >waitid() function replacement (From: "Kevin Harris" <email@hidden>)
 >Re: waitid() function replacement (From: Eric Gouriou <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.