On windows I am trying to send signal through python script and receiving it in another but in the receiving script my signal handler is not getting called. Following are the scripts : signal.py
import signal
import os
import sys
import subprocess
import time
p = subprocess.Popen([sys.executable, "a.py" ])
print "created process id :" ,p.pid
time.sleep(4)
os.kill(p.pid,signal.SIGBREAK)
err,out = p.communicate()
print err
print out
a.py
import signal
import time
import os
def signalHandler ( signum , address ):
print "IN signal handler"
print os.getpid();
signal.signal(signal.SIGTERM,signalHandler)
signal.signal(signal.SIGABRT,signalHandler)
signal.signal(signal.SIGBREAK,signalHandler)
signal.signal(signal.SIGFPE,signalHandler)
signal.signal(signal.SIGILL,signalHandler)
signal.signal(signal.SIGINT,signalHandler)
signal.signal(signal.SIGSEGV,signalHandler)
signal.signal(signal.CTRL_C_EVENT,signalHandler)
print "Going in sleep a.py"
time.sleep(10)
I am executing signal.py, which calls a.py internally. Signal.py is sender and a.py is receiver. I have tried using other signals like SIGTERM,SIGABRT,SIGFPE but was not able to catch them in a.py.