diff options
author | Erik Troan <ewt@redhat.com> | 2000-02-23 21:04:50 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2000-02-23 21:04:50 +0000 |
commit | 9118274a4e9df2a574cecc169e5fbca4dc98d2f9 (patch) | |
tree | b5c9aa7b945a00eab9659d8e81089da31c630af0 /iutil.py | |
parent | 51f5a9e60eea5c47de006440b23e33a996fff3dd (diff) | |
download | anaconda-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.py | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -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): |