The subprocess module in Python 2.4 has a race condition. If you're doing process.communicate() on more than one pipe, on a Unix-like system you may end up getting an exception (4, 'Interrupted system call') when the child process terminates, if the SIGCHLD signal arrives at an inopportune moment.

This bug appears to be fixed in Python 2.5.2, where all calls to select, read and write are wrapped in a while looks and ignore EINTR errors.

Maybe this blog post will save someone else the hour needed to study strace logs trying to figure this out.

Update: It's not fixed in upstream Python. Ubuntu patched it a year ago for python2.5, but not for python2.4. Upstream knows about the patch, but so far only a partial fix (EINTR guard around select, but not around read/write) has made it into svn trunk (but not the 2.5 maintenance branch, yet, and I'm not even thinking about 2.4).