import signal
import sys
def handler(sig,frame):
print "Handler called for signal",sig
print "Installing handler for signal", signal.SIGINT
orig_handler=signal.signal(signal.SIGINT,handler)
print "Changing handler to SIG_IGN"
signal.signal(signal.SIGINT,signal.SIG_IGN)
print "Restoring original handler"
signal.signal(signal.SIGINT,orig_handler)
print "Program terminates normally"
def main():
def f1():
print "f1 begins"
f2()
return
print "f1 returns"
def f2():
print "f2 begins"
#longjmp(env, 1)
setjmp=1
print "Program terminates: longjmp called"
return
print "f2 returns"
setjmp=0
if (setjmp == 0):
print "setjmp returned 0"
else:
print "Program terminates: longjmp called"
f1()
return
print "Program terminates normally"
if __name__=='__main__':
main()