Subprocess and pipe-fork-exec primitive

Rafael Giannetti Viotti rafaelv at
Mon Jul 30 16:39:50 CEST 2007


   I am working with the module in Python 2.4.4 and I am 
confused about it's functionality. It uses the standard pipe-fork-exec 
method to start a subprocess:

   # create pipes

   pid = fork()

   if pid == 0:
     # child

   # parent
   status = waitpid(pid, 0)

   From my experience, this primitive will fail with 'no child 
processes' at the waitpid call if the forked child dies very quickly - 
before the parent is scheduled back for execution. This seems to happen 
because Python has a default SIGCHLD handler that, in this case, will 
reap the process before the parent has the chance to do it.

   I would like to know if this is correct, or am I missing something here?


More information about the Python-list mailing list