aboutsummaryrefslogtreecommitdiffstats
path: root/src/sosreport
diff options
context:
space:
mode:
authorjwbernin <jwbernin@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-01-29 00:58:08 +0000
committerjwbernin <jwbernin@ef72aa8b-4018-0410-8976-d6e080ef94d8>2007-01-29 00:58:08 +0000
commit2929ab928af24ce7157836d4341a8b61c8eac042 (patch)
treefd21e6a402db4d20c50cc24ea9b478e18281e111 /src/sosreport
parentf487724c84b43adc8cb60b8c41db7741d9acc958 (diff)
downloadsos-2929ab928af24ce7157836d4341a8b61c8eac042.tar.gz
Basic KeyboardInterrupt / SIGTERM handling, still needs more development
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@71 ef72aa8b-4018-0410-8976-d6e080ef94d8
Diffstat (limited to 'src/sosreport')
-rwxr-xr-xsrc/sosreport29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/sosreport b/src/sosreport
index 069f1a59..711475f1 100755
--- a/src/sosreport
+++ b/src/sosreport
@@ -35,27 +35,29 @@ from snack import *
from threading import Thread, activeCount, enumerate
import signal
+
+## Set up routines to be linked to signals for termination handling
def exittermhandler(signum, frame):
+ doExitCode()
+
+def doExitCode():
if activeCount() > 1:
print "SIGTERM received, multiple threads detected, waiting for all threads to exit"
- for thread in enumerate:
+ for thread in enumerate():
thread.wait()
print "All threads ended, cleaning up."
else:
print "SIGTERM received, cleaning up"
- # Add code here to clean up /tmp
-
-def exitkillhandler(signum, frame):
- if activeCount() > 1:
- # Figure out how to kill threads and put that code here
- else:
- print "SIGKILL received, exiting without cleaning up.
+ # FIXME: Add code here to clean up /tmp
sys.exit(255)
-
+
# Handle any sort of exit signal cleanly
-# Currently, we intercept only sig 9 and 15 (KILL and TERM)
+# Currently, we intercept only sig 15 (TERM)
signal.signal(signal.SIGTERM, exittermhandler)
-signal.signal(signal.SIGKILL, exitkillhandler)
+
+## FIXME: Need to figure out how to IPC with child threads in case of
+## multiple SIGTERMs.
+## FIXME: Need to figure out how to handle SIGKILL - we can't intercept it.
if os.getuid() != 0:
@@ -352,4 +354,7 @@ def sosreport():
if __name__ == '__main__':
- sosreport()
+ try:
+ sosreport()
+ except KeyboardInterrupt:
+ doExitCode() \ No newline at end of file