In python script below, i am trying to catch SIGTERM signal (which may recived from other process) by installing my isr and overriding python default one. while this script works great in linux (not surprising), in windows it doesn't work (not surprising)!
How can i get the same behavior in windows 7?
Iam runing python 2.7 on windows 7 PC.
import os
import signal
import time
def instal_isr(SIGN, isr):
signal.signal(SIGN, isr)
def sigterm_isr(SIGN, int_stack_frame):
print 'received SIGTERM, {sign} {stackframe}'.format(sign=SIGN, stackframe=int_stack_frame)
#do some stuf and exit
exit(1)
def main():
while(True):
print 'wasting your cpu cycles'
time.sleep(2)
if __name__=='__main__':
instal_isr(signal.SIGTERM, sigterm_isr)
main()
The output in Linux:
wasting your cpu cycles
wasting your cpu cycles
wasting your cpu cycles
wasting your cpu cycles
received SIGTERM, 15 <frame object at 0x7f6261852dd0>
I have tried to get relevant information from the question in the link signal handling python on windows machine , the responds dived into details and not actually covers this "simple" case.