This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Hang in Popen.wait() when another process has been created
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6, Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: farialima, steven.k.wong, terry.reedy
Priority: normal Keywords:

Created on 2009-05-01 20:08 by farialima, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg86901 - (view) Author: François Granade (farialima) Date: 2009-05-01 20:08
If I remove the "proc2.stdin.close()" in the script below, the
"proc1.wait()" will hang. Tested on MacOS, Linux, CygWin on 2.5.2 and
2.6. Is it a bug ?

from subprocess	import Popen, PIPE
proc1 =	Popen('cat -', shell=True, stdin=PIPE, stdout=PIPE)
proc2 = Popen('cat -', shell=True, stdin=PIPE, stdout=PIPE)
# Removing this line make the proc1.wait() hang
proc2.stdin.close()

proc1.stdin.close()
proc1.wait()
msg86907 - (view) Author: François Granade (farialima) Date: 2009-05-01 20:39
Note that I use this wait(), otherwise, on CygWin, proc1 does not
properly dies, and leaves opened (undeletable - that's windows !) files
around
msg97600 - (view) Author: Steven K. Wong (steven.k.wong) Date: 2010-01-11 20:33
I think the hang is not a bug. Take a look at the Popen documentation on close_fds. If you specify close_fds=True when creating proc2, the hang will not happen when you remove the "proc2.stdin.close()" line.
msg97602 - (view) Author: Steven K. Wong (steven.k.wong) Date: 2010-01-11 20:51
See this related issue: http://bugs.python.org/issue7448
msg97603 - (view) Author: Steven K. Wong (steven.k.wong) Date: 2010-01-11 20:51
See this related issue: http://bugs.python.org/issue7213
msg112742 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-04 03:13
Closing because OP did not disagree with Wong's explanation of why not a bug. If someone disagreea and wants to reopen, this should be verified and marked for a current version (2.7+)
History
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50148
2010-08-04 03:13:57terry.reedysetstatus: open -> closed

nosy: + terry.reedy
messages: + msg112742

resolution: not a bug
2010-01-11 20:51:38steven.k.wongsetmessages: + msg97603
2010-01-11 20:51:11steven.k.wongsetmessages: + msg97602
2010-01-11 20:33:22steven.k.wongsetnosy: + steven.k.wong
messages: + msg97600
2009-05-01 20:39:51farialimasetmessages: + msg86907
2009-05-01 20:08:07farialimacreate