summaryrefslogtreecommitdiffstats
path: root/iutil.py
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>2001-03-07 20:51:36 +0000
committerErik Troan <ewt@redhat.com>2001-03-07 20:51:36 +0000
commit0db8415976e948c1700bc3f8e7e9f4e48f82a48f (patch)
tree20a181cc92cb84e4811de5ee27310265e2e1d215 /iutil.py
parent01ec55f8e00e9024829e93e60ef2349d2d6d3d05 (diff)
downloadanaconda-0db8415976e948c1700bc3f8e7e9f4e48f82a48f.tar.gz
anaconda-0db8415976e948c1700bc3f8e7e9f4e48f82a48f.tar.xz
anaconda-0db8415976e948c1700bc3f8e7e9f4e48f82a48f.zip
made execWithCapture() capture an arbitrary file descriptor, be able to throw
away another file descriptor
Diffstat (limited to 'iutil.py')
-rw-r--r--iutil.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/iutil.py b/iutil.py
index 8fe29c2ad..1965e376c 100644
--- a/iutil.py
+++ b/iutil.py
@@ -99,7 +99,8 @@ def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
return status
-def execWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0):
+def execWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0,
+ catchfd = 1, closefd = -1):
if not os.access (root + command, os.X_OK):
if not os.access (command, os.X_OK):
@@ -112,7 +113,12 @@ def execWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0):
childpid = os.fork()
if (not childpid):
if (root and root != '/'): isys.chroot (root)
- os.dup2(write, 1)
+ os.dup2(write, catchfd)
+ os.close(write)
+ os.close(read)
+
+ if closefd != -1:
+ os.close(closefd)
if stdin:
os.dup2(stdin, 0)