summaryrefslogtreecommitdiffstats
path: root/iutil.py
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2004-02-18 00:09:46 +0000
committerJeremy Katz <katzj@redhat.com>2004-02-18 00:09:46 +0000
commit133e28e56ecbaa5c533ab691a641b3e6e7ad1005 (patch)
tree8a0f5aadf12892c4a69ce57fbb164fb93d5c639d /iutil.py
parent54e578f121a502b8109846b2c419d7c74842066b (diff)
downloadanaconda-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.py21
1 files changed, 7 insertions, 14 deletions
diff --git a/iutil.py b/iutil.py
index 6793b5089..7aa0755bd 100644
--- a/iutil.py
+++ b/iutil.py
@@ -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)