Be more careful with closing fd's 0,1,2.

This commit is contained in:
Guido van Rossum 1997-10-07 14:37:31 +00:00
parent ef31b240ea
commit d6449a2b11
1 changed files with 5 additions and 3 deletions

View File

@ -110,9 +110,11 @@ def spawn(prog, args):
pid = os.fork()
if pid == 0:
# Child
os.close(0)
os.close(1)
os.close(2)
for i in 0, 1, 2:
try:
os.close(i)
except os.error:
pass
if os.dup(p2cread) <> 0:
sys.stderr.write('popen2: bad read dup\n')
if os.dup(c2pwrite) <> 1: