Re: Capturing SIGSTOP

2011-11-24 Thread Chris Angelico
On Thu, Nov 24, 2011 at 5:36 PM, Steven D'Aprano wrote: >    os.kill(os.getpid(), signal.SIGSTOP)  # Hit myself with a brick. > > > It seems to work for me (on Linux), but is it the right way? And - if your system has SIGTSTP, it'll have SIGSTOP and this will be how it works. (Windows has neither

Re: Capturing SIGSTOP

2011-11-24 Thread Chris Angelico
On Thu, Nov 24, 2011 at 5:36 PM, Steven D'Aprano wrote: >    os.kill(os.getpid(), signal.SIGSTOP)  # Hit myself with a brick. > Sometimes there'll be a raise() function but it's going to do the same thing. Yep, that would be the way to do it. ChrisA -- http://mail.python.org/mailman/listinfo/py

Re: Capturing SIGSTOP

2011-11-23 Thread Steven D'Aprano
On Thu, 24 Nov 2011 15:22:23 +1100, Chris Angelico wrote: > On Thu, Nov 24, 2011 at 2:29 PM, Steven D'Aprano > wrote: >> Is there a way to catch SIGSTOP? > > In the strictest sense, no; SIGSTOP can't be caught. However, some > systems have SIGTSTP which is sent when you hit Ctrl-Z, which would b

Re: Capturing SIGSTOP

2011-11-23 Thread Chris Angelico
On Thu, Nov 24, 2011 at 2:29 PM, Steven D'Aprano wrote: > Is there a way to catch SIGSTOP? In the strictest sense, no; SIGSTOP can't be caught. However, some systems have SIGTSTP which is sent when you hit Ctrl-Z, which would be what you're looking for. http://www.gnu.org/s/hello/manual/libc/Job

Capturing SIGSTOP

2011-11-23 Thread Steven D'Aprano
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: Tracebac