Commit b3bfb1cd authored by Pulkit Goyal's avatar Pulkit Goyal
Browse files

procutil: use os.devnull if sys.stdout/err is None

According to Yuya, it's better to make `procutil.stdin/err/out` always
available.

This is a bandaid until someone suggests something better.
parent e40f52691dac
Pipeline #14888 passed with stage
in 34 minutes and 19 seconds
...@@ -131,8 +131,16 @@ if pycompat.ispy3: ...@@ -131,8 +131,16 @@ if pycompat.ispy3:
else: else:
stdin = open(os.devnull, 'rb') stdin = open(os.devnull, 'rb')
os.close(stdin.fileno()) os.close(stdin.fileno())
stdout = _make_write_all(sys.stdout.buffer) if sys.stdout:
stderr = _make_write_all(sys.stderr.buffer) stdout = _make_write_all(sys.stdout.buffer)
else:
stdout = open(os.devnull, 'rb')
os.close(stdout.fileno())
if sys.stderr:
stderr = _make_write_all(sys.stderr.buffer)
else:
stderr = open(os.devnull, 'rb')
os.close(stderr.fileno())
if pycompat.iswindows: if pycompat.iswindows:
# Work around Windows bugs. # Work around Windows bugs.
stdout = platform.winstdout(stdout) stdout = platform.winstdout(stdout)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment