How to handle the signal in python on windows machine
问题 I am trying the code pasted below on Windows, but instead of handling signal, it is killing the process. However, the same code is working in Ubuntu. import os, sys import time import signal def func(signum, frame): print 'You raised a SigInt! Signal handler called with signal', signum signal.signal(signal.SIGINT, func) while True: print "Running...",os.getpid() time.sleep(2) os.kill(os.getpid(),signal.SIGINT) 回答1: Python's os.kill wraps two unrelated APIs on Windows. It calls