Signal handler & cygwin

gervaz gervaz at gmail.com
Sat Dec 25 20:46:04 EST 2010


Hi all, given the followin code snippet:

import signal
import time
import sys
import os

print("{0}\n".format(os.getpid()))

ContinueProcessing = True

def stop(signal, frame):
    print("\nSignal received!\n")
    time.sleep(1)
    global ContinueProcessing
    ContinueProcessing = False

signal.signal(signal.SIGINT, stop)

while ContinueProcessing:
    try:
        sys.stdout.write(".")
        sys.stdout.flush()
        time.sleep(0.1)
    except:
        continue

if I kill the process using kill -s SIGINT PID in linux everything
works fine and the signal is correctly handled, while in win, using
cywin (/bin/kill.exe -f -s SIGINT WINPID), the program just exits
without trapping the interrupt.

Any similar experience?



More information about the Python-list mailing list