I'd like to wait for some children without blocking when the child didn't exit.
Calling posix.wait() or posix.waitpid(pid,0) waits for the children to
complete, it hangs if the child hasn't finished. What I really want to do is
to call:
posix.waitpid(pid,WNOHANG)
Unfortunately, WNOHANG is not exported from posix nor defined anywhere else in
pyhton. Even more unfortunately, WNOHANG has a different value on different
UNIX flavors. E.g:
sunos 4.1.3 : #define WNOHANG 1
Solaris 2.4 : #define WNOHANG 0100
OSF1 2.0 : #define WNOHANG 0x1
Ultrix 4.4 : #define WNOHANG 1
irix 4.0.5C : #define WNOHANG 0x1
irix 5.2 : #define WNOHANG 0100
irix 6.0.1 : #define WNOHANG 0100
Q: Is there another way to wait without hanging?
I tryied to install a signal handler on SIGCHLD. But for some reasons, I
don't wait for all children, because some signals get lost, or even worse
I get into a state, where I don't get any SIGCHLD signal anymore. After a
while my process can't fork anymore because there are too many unwaited
children (on irix 6.0.1) :-(.
Q: Would it make sense to export WNOHANG from the posix module?
I just browsed Guidos source code <http://www.cwi.nl/cwi/people/Guido.van.Rossum/python-src/Modules/posixmodule.c>.
It isn't there in version 1.2. Wouldn't this be a nice feature for version
1.2.
Michael
-- ___ _ _ ___ _ *** | __) | \/ | | ) | | Michael Scharf ***** | _) | | | -< | |_ EMail: scharf@EMBL-Heidelberg.de * * |___) |_||_| |___) |___) http://www.EMBL-Heidelberg.de/~scharf/