signal handler
Thooney Millennier
too at pk.highway.ne.jp
Mon Jun 28 10:30:41 EDT 1999
I am sorry for my late reply,
and thank for your suggestion.
I did't know functions such as
"getpid()","kill()".
Well, I tried and realized...
If you use "kill(getpid(),SIGINT)",
it works. (ie. callback ok!)
Instead,if you send "Control-C" by keyboard input,
it does not. (nothing happens,signal ignored)
It is confusing.
Thooney.
Ovidiu Predescu wrote:
>> Hi, I want to use "signal()" in my program.
>>
>> import signal;
>> def func(arg1,arg2):
>> DO_SOMETHING_GOOD;
>> print "OK!";
>> signal.signal(SOME_SIGNAL,func);
>>
>> It seems "func()" is not called
>> when the program gets signal "SOME_SIGNAL".
>> Why?
>
> It looks like you forgot to send the signal. One way you could
> implement this code is:
>
> from signal import signal, SIGINT
> from os import getpid, kill
>
> def signalHandler (signum, frame):
> print 'signal handler called for signal %d' % (signum,)
>
> signal (SIGINT, signalHandler)
> kill (getpid (),
>
More information about the Python-list
mailing list