1

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?

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Somputer
  • 1,223
  • 2
  • 11
  • 20
  • I don't know if SIGINT exists on Windows. You might want to check out this question: http://stackoverflow.com/questions/813086/can-i-send-a-ctrl-c-sigint-to-an-application-on-windows – Eric Renouf May 12 '15 at 01:29
  • i don't want kill program.. i just want to send cntrl-c in self program.. – Somputer May 12 '15 at 01:35
  • @EricRenouf: Yeah, SIGINT is not a Windows thing at all. (*nix signals aren't actually a Windows thing, even; there are broadly similar mechanisms, but they don't map cleanly.) – Nathan Tuggy May 12 '15 at 01:35

1 Answers1

1
from win32api import GenerateConsoleCtrlEvent
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0)
Somputer
  • 1,223
  • 2
  • 11
  • 20