]> granicus.if.org Git - python/commitdiff
Be more careful with closing fd's 0,1,2.
authorGuido van Rossum <guido@python.org>
Tue, 7 Oct 1997 14:37:31 +0000 (14:37 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 7 Oct 1997 14:37:31 +0000 (14:37 +0000)
Demo/tkinter/guido/ShellWindow.py

index 0b59daacbf4051881d3272dcd6e1bd7d7ba32503..98fe30f70dcd23577ee043f280a54427c14ba0f0 100755 (executable)
@@ -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: