Issue 34233: subprocess.check_output goes to infinte loop (original) (raw)
Issue34233
Created on 2018-07-26 10:44 by sanjay patel, last changed 2022-04-11 14:59 by admin. This issue is now closed.
Messages (2) | ||
---|---|---|
msg322413 - (view) | Author: sanjay patel (sanjay patel) | Date: 2018-07-26 10:44 |
Below snipped goes to infinite loop when running through windows command prompt but works in python IDLE import subprocess subprocess.check_output('cmd.exe dir', stderr=subprocess.STDOUT) save as:test.py in windows cmd use command: python test.py then it goes to infine loop but the same program works in Python IDLE. | ||
msg322416 - (view) | Author: Eryk Sun (eryksun) * ![]() |
Date: 2018-07-26 11:30 |
`cmd.exe dir` ignores the unrecognized `dir` argument and runs the interactive shell. The shell is waiting for input on stdin. You can type "exit" and press enter to return to Python. When you run this from IDLE (i.e. via pythonw.exe), there's no StandardInput handle to inherit, so subprocess executes cmd.exe with its stdin set to a closed pipe. (I don't know why a closed pipe is used. I think "NUL" would be better.) The shell exits immediately because ReadFile fails with ERROR_BROKEN_PIPE. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:59:03 | admin | set | github: 78414 |
2018-07-26 11:30:00 | eryksun | set | status: open -> closednosy: + eryksunmessages: + resolution: not a bugstage: resolved |
2018-07-26 10:44:12 | sanjay patel | create |