summaryrefslogtreecommitdiffstats
path: root/exception.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2005-12-13 21:12:02 +0000
committerDavid Cantrell <dcantrell@redhat.com>2005-12-13 21:12:02 +0000
commit44223e46715ee89dd63c9554ec9a17919ca3f091 (patch)
tree58f2ac8e88af24208a12acf30b2cf7dce08bc4e0 /exception.py
parent15349e623dbe98f1c349b01c9b6e18b01dea5e32 (diff)
downloadanaconda-44223e46715ee89dd63c9554ec9a17919ca3f091.tar.gz
anaconda-44223e46715ee89dd63c9554ec9a17919ca3f091.tar.xz
anaconda-44223e46715ee89dd63c9554ec9a17919ca3f091.zip
* anaconda: Record the PID of the forked process that handles
spawning the shell when you are using the VNC mode. * iutil.py (execWithRedirect): If we see /tmp/vncshell.pid, record the PID of whatever we just spawned. * exception.py (handleException): If we see /tmp/vncshell.pid, open it and kill everything listed. Attempt to reclaim std IO. Drop to pdb after we have made sure the shell and spawning loop are dead. Generic comment: Statements like "if not child:" are misleading because that test would be true if it actually was the child. I have changed a few to "if child == 0:" to make it more readable.
Diffstat (limited to 'exception.py')
-rw-r--r--exception.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/exception.py b/exception.py
index 292f826dc..31f8b0835 100644
--- a/exception.py
+++ b/exception.py
@@ -367,6 +367,30 @@ def handleException(dispatch, intf, (type, value, tb)):
elif rc == 1:
intf.__del__ ()
print text
+
+ pidfl = "/tmp/vncshell.pid"
+ if os.path.exists(pidfl) and os.path.isfile(pidfl):
+ pf = open(pidfl, "r")
+ for pid in pf.readlines():
+ if not int(pid) == os.getpid():
+ os.kill(int(pid), signal.SIGKILL)
+ pf.close()
+
+ os.open("/dev/console", os.O_RDWR) # reclaim stdin
+ os.dup2(0, 1) # reclaim stdout
+ os.dup2(0, 2) # reclaim stderr
+ # ^
+ # |
+ # +------ dup2 is magic, I tells ya!
+
+ # bring back the echo
+ import termios
+ si = sys.stdin.fileno()
+ attr = termios.tcgetattr(si)
+ attr[3] = attr[3] & termios.ECHO
+ termios.tcsetattr(si, termios.TCSADRAIN, attr)
+
+ print "\nEntering debugger..."
import pdb
pdb.post_mortem (tb)
os.kill(os.getpid(), signal.SIGKILL)