bug in pclose(3)

Matt Landau mlandau at bbn.com
Wed Dec 21 05:27:53 AEST 1988


[Earlier article describes some race conditions that can lead to 
 program hanging if they popen() multiple things and then close them 
 in a certain order. . .]

I've found the same sort of behavior in BSD-derived systems, with both
popen and system.  The basic problem is that in both cases, the library
routines will wait for the process they're interested in to terminate,
but will catch and discard termination information for other processes
silently.

The only completely reliable solution for our application turned out
to be the rule "don't use popen/pclose or system for general process
control functions."  Instead, we wrote a set of library routines to 
manage multiple child processes cleanly - they know how to start, send
input to, get input from, and kill any of the set of running children
without affecting the others.



More information about the Comp.unix.wizards mailing list