summaryrefslogtreecommitdiffstats
path: root/iutil.py
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>2000-02-23 21:04:50 +0000
committerErik Troan <ewt@redhat.com>2000-02-23 21:04:50 +0000
commit9118274a4e9df2a574cecc169e5fbca4dc98d2f9 (patch)
treeb5c9aa7b945a00eab9659d8e81089da31c630af0 /iutil.py
parent51f5a9e60eea5c47de006440b23e33a996fff3dd (diff)
downloadanaconda-9118274a4e9df2a574cecc169e5fbca4dc98d2f9.tar.gz
anaconda-9118274a4e9df2a574cecc169e5fbca4dc98d2f9.tar.xz
anaconda-9118274a4e9df2a574cecc169e5fbca4dc98d2f9.zip
various changes to get better ^C, ^Z handling
Diffstat (limited to 'iutil.py')
-rw-r--r--iutil.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/iutil.py b/iutil.py
index a2e3c0ff6..7c7335ada 100644
--- a/iutil.py
+++ b/iutil.py
@@ -1,5 +1,5 @@
-import types, os, sys, isys, select, string, stat
+import types, os, sys, isys, select, string, stat, signal
def getArch ():
arch = os.uname ()[4]
@@ -24,7 +24,8 @@ def getfd(filespec, readOnly = 0):
return os.open(filespec, flags)
def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
- searchPath = 0, root = '/'):
+ searchPath = 0, root = '/', newPgrp = 0,
+ ignoreTermSigs = 0):
stdin = getfd(stdin)
if stdout == stderr:
stdout = getfd(stdout)
@@ -43,6 +44,10 @@ def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
if (not childpid):
if (root and root != '/'): isys.chroot (root)
+ if ignoreTermSigs:
+ 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"):
@@ -67,8 +72,17 @@ def execWithRedirect(command, argv, stdin = 0, stdout = 1, stderr = 2,
os.execv(command, argv)
sys.exit(1)
+
+ if newPgrp:
+ os.setpgid(childpid, childpid)
+ oldPgrp = os.tcgetpgrp(0)
+ os.tcsetpgrp(0, childpid)
+
(pid, status) = os.waitpid(childpid, 0)
+ if newPgrp:
+ os.tcsetpgrp(0, oldPgrp)
+
return status
def execWithCapture(command, argv, searchPath = 0, root = '/', stdin = 0):