Hello I am trying to set up a SIGKILL handling signal with python's signal
module, but getting an OSError exception.
Python: 3.7.5
OS: MacOS Mojave
class MyClass:
def __init__(self, *args, **kwargs):
signal.signal(signal.SIGKILL, self.gracefull_shutdown)
signal.signal(signal.SIGTERM, self.gracefull_shutdown)
def gracefull_shutdown(self, signum, frame):
# gracefull_shutdown code here
which gives me the following
signal.signal(signal.SIGKILL, self.gracefull_shutdown)
File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
OSError: [Errno 22] Invalid argument
SIGTERM handling works, (by commenting out the SIGKILL
handler). I read that MacOS supports SIGKILL, isn't that right?
From the
man 7 signal
, it saysAnd also please refer to how to handle os.system sigkill signal inside python?