diff options
author | Jeremy Katz <katzj@redhat.com> | 2004-02-18 00:09:46 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2004-02-18 00:09:46 +0000 |
commit | 133e28e56ecbaa5c533ab691a641b3e6e7ad1005 (patch) | |
tree | 8a0f5aadf12892c4a69ce57fbb164fb93d5c639d /iutil.py | |
parent | 54e578f121a502b8109846b2c419d7c74842066b (diff) | |
download | anaconda-133e28e56ecbaa5c533ab691a641b3e6e7ad1005.tar.gz anaconda-133e28e56ecbaa5c533ab691a641b3e6e7ad1005.tar.xz anaconda-133e28e56ecbaa5c533ab691a641b3e6e7ad1005.zip |
only open fds for stdin, stderr, and stdout in the child to avoid holding
things open (#114771)
Diffstat (limited to 'iutil.py')
-rw-r--r-- | iutil.py | 21 |
1 files changed, 7 insertions, 14 deletions
@@ -49,14 +49,6 @@ def getfd(filespec, readOnly = 0): def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2, searchPath = 0, root = '/', newPgrp = 0, ignoreTermSigs = 0): - stdin = getfd(stdin) - if stdout == stderr: - stdout = getfd(stdout) - stderr = stdout - else: - stdout = getfd(stdout) - stderr = getfd(stderr) - if not searchPath and not os.access (root + command, os.X_OK): raise RuntimeError, command + " can not be run" @@ -70,12 +62,13 @@ def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2, signal.signal(signal.SIGTSTP, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN) - if type(stdin) == type("a"): - stdin == os.open(stdin, os.O_RDONLY) - if type(stdout) == type("a"): - stdout == os.open(stdout, os.O_RDWR) - if type(stderr) == type("a"): - stderr = os.open(stderr, os.O_RDWR) + stdin = getfd(stdin) + if stdout == stderr: + stdout = getfd(stdout) + stderr = stdout + else: + stdout = getfd(stdout) + stderr = getfd(stderr) if stdin != 0: os.dup2(stdin, 0) |