Sublime Forum

[ST3] file handles broken in subprocess

#1

There is a really strange behavior with subprocesses and the output file handles. If you capture one of them (stdout or stderr) with subprocess.PIPE, the other one can’t be written by the subprocess. Capturing both or none works fine:

[code]>>> p = subprocess.Popen(‘ls’, ‘non_existent’])

p.wait()
1

p = subprocess.Popen(‘ls’, ‘non_existent’], stdout=subprocess.PIPE)
p.communicate()
(b’’, None)

p.returncode
68864

p = subprocess.Popen(‘ls’, ‘non_existent’], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.communicate()
(b’’, b’ls: non_existent: No such file or directory\n’)

p.returncode
1

p = subprocess.Popen(‘ls’], stderr=subprocess.PIPE)
p.communicate()
(None, b’’)

p.returncode
68864[/code]

0 Likes