[svn r37866] small cleanup of ground std* descriptors.

--HG--
branch : trunk
This commit is contained in:
hpk 2007-02-03 13:31:47 +01:00
parent f5d51fb9e0
commit d6d7eb8704
1 changed files with 7 additions and 4 deletions

View File

@ -171,16 +171,19 @@ def stdouterrin_setnull():
devnull = 'NUL' devnull = 'NUL'
else: else:
devnull = '/dev/null' devnull = '/dev/null'
# stdin
sys.stdin = os.fdopen(os.dup(0), 'rb', 0) sys.stdin = os.fdopen(os.dup(0), 'rb', 0)
sys.stdout = os.fdopen(os.dup(1), 'wb', 0)
if os.name == 'nt':
sys.stderr = os.fdopen(os.dup(2), 'wb', 0)
fd = os.open(devnull, os.O_RDONLY) fd = os.open(devnull, os.O_RDONLY)
os.dup2(fd, 0) os.dup2(fd, 0)
os.close(fd) os.close(fd)
# stdout
sys.stdout = os.fdopen(os.dup(1), 'wb', 0)
fd = os.open(devnull, os.O_WRONLY) fd = os.open(devnull, os.O_WRONLY)
os.dup2(fd, 1) os.dup2(fd, 1)
# stderr for win32
if os.name == 'nt': if os.name == 'nt':
sys.stderr = os.fdopen(os.dup(2), 'wb', 0)
os.dup2(fd, 2) os.dup2(fd, 2)
os.close(fd) os.close(fd)