con : : /usr/bin/ps kill - got signal at sun mar : : kill - got signal at sun mar : : kill - [ ]killed python signal py inputs and outputs can be bit jumbled here because the process prints to the same screen used to type new shell commands to send the program signalthe kill shell command takes signal number and process id to be signaled ( )every time new kill command sends signalthe process replies with message generated by python signal handler function signal always kills the process altogether the signal module also exports signal alarm function for scheduling sigalrm signal to occur at some number of seconds in the future to trigger and catch timeoutsset the alarm and install sigalrm handler as shown in example - example - pp \system\processes\signal py ""set and catch alarm timeout signals in pythontime sleep doesn' play well with alarm (or signal in general in my linux pc)so we call signal pause here to do nothing until signal is received""import syssignaltime def now()return time asctime(def onsignal(signumstackframe)print('got alarm'signum'at'now()python signal handler most handlers stay in effect while trueprint('setting at'now()signal signal(signal sigalrmonsignalsignal alarm( signal pause(install signal handler do signal in seconds wait for signals running this script on cygwin on windows causes its onsignal handler function to be invoked every five seconds[ :\pp \system\processes]python signal py setting at sun mar : : got alarm at sun mar : : setting at sun mar : : got alarm at sun mar : : setting at sun mar : : got alarm at sun mar : : setting at sun mar : : got alarm at sun mar : : parallel system tools