source: trunk/lang/python/Rappture/signalHandler.py @ 4346

Last change on this file since 4346 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 2.3 KB
Line 
1# ----------------------------------------------------------------------
2#
3# ======================================================================
4#  AUTHOR:  Derrick Kearney, Purdue University
5#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
6# ======================================================================
7
8import sys
9import signal
10
11qID = []
12queue_type = ''
13
14def sigGEN_handler(signal, frame):
15    global qID
16    global queue_type
17    if qID :
18        for id in xrange(len(qID)):
19            sys.stdout.write("Killing job with qID = :%s:\n" % (qID[id]))
20            sys.stdout.flush()
21            if queue_type == 'PBS':
22                rmCmdOut = getCommandOutput('qdel %s' % (qID[id]))
23            elif queue_type == 'Condor':
24                rmCmdOut = getCommandOutput('condor_rm %s' % (qID[id]))
25            else:
26                # unrecognized queue_type
27                break
28            sys.stdout.write("\n%s\n" % rmCmdOut)
29            sys.stdout.flush()
30            time.sleep(10)
31    sys.stdout.write("\nEXITING...\n")
32    sys.stdout.flush()
33    sys.exit(-1)
34
35
36def sigINT_handler(signal, frame):
37    sys.stdout.write('Received SIGINT!\n')
38    sys.stdout.flush()
39    sigGEN_handler(signal, frame)
40
41def sigHUP_handler(signal, frame):
42    sys.stdout.write('Received SIGHUP!\n')
43    sys.stdout.flush()
44    sigGEN_handler(signal, frame)
45
46def sigQUIT_handler(signal, frame):
47    sys.stdout.write('Received SIGQUIT!\n')
48    sys.stdout.flush()
49    sigGEN_handler(signal, frame)
50
51def sigABRT_handler(signal, frame):
52    sys.stdout.write('Received SIGABRT!\n')
53    sys.stdout.flush()
54    sigGEN_handler(signal, frame)
55
56def sigTERM_handler(signal, frame):
57    sys.stdout.write('Received SIGTERM!\n')
58    sys.stdout.flush()
59    sigGEN_handler(signal, frame)
60
61def sigSTOP_handler(signal, frame):
62    sys.stdout.write('Received SIGSTOP!\n')
63    sys.stdout.flush()
64    sigGEN_handler(signal, frame)
65
66def sigKILL_handler(signal, frame):
67    sys.stdout.write('Received SIGKILL!\n')
68    sys.stdout.flush()
69    sigGEN_handler(signal, frame)
70
71signal.signal(signal.SIGINT, sigINT_handler)
72signal.signal(signal.SIGHUP, sigHUP_handler)
73signal.signal(signal.SIGQUIT, sigQUIT_handler)
74signal.signal(signal.SIGABRT, sigABRT_handler)
75signal.signal(signal.SIGTERM, sigTERM_handler)
76#signal.signal(signal.SIGSTOP, sigSTOP_handler)
77#signal.signal(signal.SIGKILL, sigKILL_handler)
78
Note: See TracBrowser for help on using the repository browser.