summaryrefslogtreecommitdiffstats
path: root/iutil.py
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>1999-05-05 18:27:01 +0000
committerErik Troan <ewt@redhat.com>1999-05-05 18:27:01 +0000
commit4546fda88d69ab19fc94ea1b7c27a7e775e10039 (patch)
treecc75f4a91582f0893cb67153d8c15618802f2f52 /iutil.py
parent51c3d0a2623b1f88ba9c5298a24c68254249ab72 (diff)
downloadanaconda-4546fda88d69ab19fc94ea1b7c27a7e775e10039.tar.gz
anaconda-4546fda88d69ab19fc94ea1b7c27a7e775e10039.tar.xz
anaconda-4546fda88d69ab19fc94ea1b7c27a7e775e10039.zip
*** empty log message ***
Diffstat (limited to 'iutil.py')
-rw-r--r--iutil.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/iutil.py b/iutil.py
new file mode 100644
index 000000000..b87ed6137
--- /dev/null
+++ b/iutil.py
@@ -0,0 +1,41 @@
+
+import types, os, sys
+
+def getfd(filespec, readOnly = 0):
+ if type(filespec) == types.IntType:
+ return filespec
+ if filespec == None:
+ filespec = "/dev/null"
+
+ flags = os.O_RDWR | os.O_CREAT
+ if (readOnly):
+ flags = os.O_RDONLY
+ return os.open(filespec, flags)
+
+def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
+ searchPath = 0):
+ stdin = getfd(stdin)
+ stdout = getfd(stdout)
+ stderr = getfd(stderr)
+
+ childpid = os.fork()
+ if (not childpid):
+ if stdin != 0:
+ os.dup2(stdin, 0)
+ os.close(stdin)
+ if stdout != 1:
+ os.dup2(stdout, 1)
+ os.close(stdout)
+ if stderr != 2:
+ os.dup2(stderr, 2)
+ os.close(stderr)
+
+ if (searchPath):
+ os.execvp(command, argv)
+ else:
+ os.execv(command, argv)
+
+ sys.exit(1)
+ status = os.waitpid(childpid, 0)
+
+