1 | # ---------------------------------------------------------------------- |
---|
2 | # |
---|
3 | # ====================================================================== |
---|
4 | # AUTHOR: Derrick Kearney, Purdue University |
---|
5 | # Copyright (c) 2005 Purdue Research Foundation, West Lafayette, IN |
---|
6 | # ====================================================================== |
---|
7 | |
---|
8 | import sys |
---|
9 | import signal |
---|
10 | |
---|
11 | qID = [] |
---|
12 | queue_type = '' |
---|
13 | |
---|
14 | def 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 | |
---|
36 | def sigINT_handler(signal, frame): |
---|
37 | sys.stdout.write('Received SIGINT!\n') |
---|
38 | sys.stdout.flush() |
---|
39 | sigGEN_handler(signal, frame) |
---|
40 | |
---|
41 | def sigHUP_handler(signal, frame): |
---|
42 | sys.stdout.write('Received SIGHUP!\n') |
---|
43 | sys.stdout.flush() |
---|
44 | sigGEN_handler(signal, frame) |
---|
45 | |
---|
46 | def sigQUIT_handler(signal, frame): |
---|
47 | sys.stdout.write('Received SIGQUIT!\n') |
---|
48 | sys.stdout.flush() |
---|
49 | sigGEN_handler(signal, frame) |
---|
50 | |
---|
51 | def sigABRT_handler(signal, frame): |
---|
52 | sys.stdout.write('Received SIGABRT!\n') |
---|
53 | sys.stdout.flush() |
---|
54 | sigGEN_handler(signal, frame) |
---|
55 | |
---|
56 | def sigTERM_handler(signal, frame): |
---|
57 | sys.stdout.write('Received SIGTERM!\n') |
---|
58 | sys.stdout.flush() |
---|
59 | sigGEN_handler(signal, frame) |
---|
60 | |
---|
61 | def sigSTOP_handler(signal, frame): |
---|
62 | sys.stdout.write('Received SIGSTOP!\n') |
---|
63 | sys.stdout.flush() |
---|
64 | sigGEN_handler(signal, frame) |
---|
65 | |
---|
66 | def sigKILL_handler(signal, frame): |
---|
67 | sys.stdout.write('Received SIGKILL!\n') |
---|
68 | sys.stdout.flush() |
---|
69 | sigGEN_handler(signal, frame) |
---|
70 | |
---|
71 | signal.signal(signal.SIGINT, sigINT_handler) |
---|
72 | signal.signal(signal.SIGHUP, sigHUP_handler) |
---|
73 | signal.signal(signal.SIGQUIT, sigQUIT_handler) |
---|
74 | signal.signal(signal.SIGABRT, sigABRT_handler) |
---|
75 | signal.signal(signal.SIGTERM, sigTERM_handler) |
---|
76 | #signal.signal(signal.SIGSTOP, sigSTOP_handler) |
---|
77 | #signal.signal(signal.SIGKILL, sigKILL_handler) |
---|
78 | |
---|