Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6449a2

Browse files
committed
Be more careful with closing fd's 0,1,2.
1 parent ef31b24 commit d6449a2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Demo/tkinter/guido/ShellWindow.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@ def spawn(prog, args):
110110
pid = os.fork()
111111
if pid == 0:
112112
# Child
113-
os.close(0)
114-
os.close(1)
115-
os.close(2)
113+
for i in 0, 1, 2:
114+
try:
115+
os.close(i)
116+
except os.error:
117+
pass
116118
if os.dup(p2cread) <> 0:
117119
sys.stderr.write('popen2: bad read dup\n')
118120
if os.dup(c2pwrite) <> 1:

0 commit comments

Comments
 (0)