Capturing SIGSTOP

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Nov 23 22:29:16 EST 2011


I'd like to perform a task when the user interrupts my application with 
Ctrl-Z on Linux. I tried installing a signal handler:


import signal

def handler(signalnum, stackframe):
    print "Received signal %d" % signalnum

signal.signal(signal.SIGSTOP, handler)

But I got a RuntimeError:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: (22, 'Invalid argument')


This isn't documented:

http://docs.python.org/library/signal.html#signal.signal


Is there a way to catch SIGSTOP?



-- 
Steven



More information about the Python-list mailing list