From 85d9f6054fac84e2f7f9511acb06e4b1d738b55c Mon Sep 17 00:00:00 2001 From: jwbernin Date: Thu, 15 Feb 2007 03:32:37 +0000 Subject: Bit further towards proper interrupt handling git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@73 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- src/sosreport | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/sosreport') diff --git a/src/sosreport b/src/sosreport index 711475f1..278d1d00 100755 --- a/src/sosreport +++ b/src/sosreport @@ -35,19 +35,27 @@ from snack import * from threading import Thread, activeCount, enumerate import signal +__breakHits__ = 0 # Use this to track how many times we enter the exit routine ## Set up routines to be linked to signals for termination handling def exittermhandler(signum, frame): doExitCode() def doExitCode(): - if activeCount() > 1: + global __breakHits__ + __breakHits__ += 1 + if ( ( activeCount() > 1 ) and ( __breakHits__ == 1 ) ): print "SIGTERM received, multiple threads detected, waiting for all threads to exit" for thread in enumerate(): thread.wait() print "All threads ended, cleaning up." - else: - print "SIGTERM received, cleaning up" + if ( ( activeCount() > 1 ) and ( __breakHits__ > 1 ) ): + print "Multiple SIGTERMs, multiple threads, attempting to signal threads to die immediately" + ## FIXME: Add thread-kill code (see FIXME below) + print "Threads dead, cleaning up. + if ( ( activeCount() == 1 ) and ( __breakHits__ > 2 ) ): + print "Multiple SIGTERMs, single thread, exiting without cleaning up. + sys.exit(3) # FIXME: Add code here to clean up /tmp sys.exit(255) -- cgit