(类似于this question)
在Python 2.7下的UNIX上,在Python提示符下:
>>> import signal
>>> def handler(signal, frame):
... print 'welcome to the handler'
...
>>> signal.signal(signal.SIGINT, handler)
<built-in function default_int_handler>
我按ctrl-c
^{pr2}$在Windows上:
>>> import signal
>>> def handler(signal, frame):
... print 'welcome to the handler'
...
>>> signal.signal(signal.SIGINT, handler)
<built-in function default_int_handler>
按ctrl-c后:
>>>
keyboardInterrupt
>>>
我可以验证handler
是否作为SIGINT的处理程序安装在Python端(调用signal.signal
第二个计时器返回myhandler
)。如何在Windows上捕获SIGINT?在
在打开上游的the bug之后,找到了问题的根本原因,并编写了一个补丁。这个补丁不会进入python2.x系列。在
相关问题 更多 >
编程相关推荐