Somputer
Somputer

Reputation: 1283

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?

Upvotes: 1

Views: 1553

Answers (1)

Somputer
Somputer

Reputation: 1283

from win32api import GenerateConsoleCtrlEvent
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0)

Upvotes: 1

Related Questions