简体   繁体   English

使用Python在Windows中发送SIGINT

[英]Send SIGINT in Windows using Python

I try this code in Linux: 我在Linux中尝试以下代码:

import os
import signal

for i in range(10000):
    print i
    if i==6666:
        os.kill(os.getpid(),signal.SIGINT)

it works well. 它运作良好。 But it doesn't work in Windows, because the attribute 'kill' is not present in os module for Windows 但这在Windows中不起作用,因为Windows的os模块中没有'kill'属性

How can I send SIGINT to self program in Windows? 如何在Windows中将SIGINT发送到自编程?

from win32api import GenerateConsoleCtrlEvent
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM