import sys, signal, time
def now():
return time.asctime()
def onSignal(signum, stackframe): # Python signal handler
print('Got signal', signum, 'at', now()) # most handlers stay in effect
if signum == signal.SIGCHLD: # but sigchld handler is not
print('sigchld caught')
#signal.signal(signal.SIGCHLD, onSignal)
signum = int(sys.argv[1])
signal.signal(signum, onSignal) # install signal handler
while True: signal.pause() # sleep waiting for signals