From: utzoo!henry Newsgroups: net.bugs.v7 Title: popen/pclose bugs Article-I.D.: utzoo.2747 Posted: Thu Jan 13 20:45:34 1983 Received: Thu Jan 13 20:45:34 1983 As came up in connection with a recent Notesfiles failure, popen(3) as it comes with V7 (etc) has a bug: it does not close the pipe descriptors if the fork fails. The fix (first pointed out by Berry Kercheval of Zehntel) is to change the code at about line 28 from: if(pid == -1) return NULL; to if (pid == -1) { close(myside); close(hisside); return NULL; } There is a further bug which I came across in the course of looking at popen and pclose. Since there is no way to wait(2) selectively for a specific process, the return code from pclose is unreliable in the event of multiple simultaneous popen's or other child processes.