ATLAS Offline Software
Loading...
Searching...
No Matches
trfSignal.py
Go to the documentation of this file.
1# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
10
11import signal
12
13import logging
14msg = logging.getLogger(__name__)
15
16_savedSignalHandlerDict = {}
17
18# N.B. Do not catch SIGINT (^C). This is delt with more cleanly via
19# the stdTrfExceptionHandler wrapper which handles the KeyboardInterrupt exception.
20# Also, don't intercept SIGTERM as this is used by the multiprocessing module to
21# terminate child proceses
22_defaultSignalList = ['SIGABRT', 'SIGFPE', 'SIGBUS', 'SIGHUP', 'SIGILL', 'SIGIO', 'SIGPIPE', 'SIGQUIT', 'SIGSEGV', 'SIGSYS', 'SIGXCPU', 'SIGXFSZ']
23
24
29 for s in _defaultSignalList:
30 try:
31 msg.debug("Setting signalhandler for %s to %s", s, handler)
32 _savedSignalHandlerDict[s] = signal.signal(getattr(signal, s), handler)
33 except Exception as e:
34 msg.error("Unable to attach custom signal handler to %s: %s", s, e)
35 continue
36
37
41 for s in _defaultSignalList:
42 try:
43 signal.signal(getattr(signal, s), _savedSignalHandlerDict.get(s, signal.SIG_DFL))
44 except Exception as e:
45 msg.error("Unable to attach custom signal handler to %s: %s", s, e)
46 continue
setTrfSignalHandlers(handler)
Install common handler for various signals.
Definition trfSignal.py:28
resetTrfSignalHandlers()
Restore signal handlers to the default ones.
Definition trfSignal.py:40