简体   繁体   中英

Send SIGINT in Windows using Python

I try this code in 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

How can I send SIGINT to self program in Windows?

from win32api import GenerateConsoleCtrlEvent
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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