[Zope-dev] Fwd: Calling os.waitpid() From Secondary Thread Under Linux 2.2.12-20?

Patrick Phalen zope@teleo.net
Tue, 11 Apr 2000 11:03:03 -0700


This just appeared on comp.lang.python.

Can any Zope experts comment on whether this Linux threads comment has
implications for Zope?


----------  ## Forwarded Message ##  ----------
Subject: Calling os.waitpid() From Secondary Thread Under Linux 2.2.12-20?
Date: Tue, 11 Apr 2000 17:48:11 GMT
From: rwiserREMOVEthis@mindspring.com (Randy Wiser)

I've written a small python program that spawns one child process from
its main thread, and then creates a second thread.  The sole purpose
of the second thread (at this point) is to call os.waitpid(processID,
0) to wait for the child that the main thread created.  This works
fine under Solaris when I call os.waitpid() from the second thread. 

But, under Linux 2.2.12-20 I get the following OSError exception:

[Errno 10] No child processes

However, if (under Linux still) I call waitpid() from the main thread
(as a test), the call does indeed wait until the child process
terminates.

After scouring some of the Linux newsgroups, I've gathered that
threads spawned under Linux may have SIGCHLD signals (and other
signals) blocked, and that this _may_ be the reason I get the error,
even though the processID I pass is for a valid process.

Unfortunately there seems to be no easy way to set the signal mask for
the second thread.  Has anyone else run into this situation, and if so
can you advise how you solved it?

-------------------------------------------------------