the signals ctrl and kill are handled correctly:
signal --> exit_func --> loop --> main
but at end of main it stops but the process indigohost does not stop. -- return() does not do anything and exit() throws an indigo error
do I need to kill -9 the PID in the program to terminate itself/indigohost as indicated?
When using the program with regular python it exits fine
Karl
- Code: Select all
import sys, time, signal, os
def exit_func(signum, func=None):
global quitNow
quitNow = 'yes'
print 'exit call with ' + quitNow + ' ' +str(signum)
return (0)
def theloop():
global quitNow
while quitNow == 'no':
print 'in loop ' + quitNow
time.sleep(3)
print ' in theloop program ' + quitNow
return (0)
if __name__ == "__main__":
global quitNow
quitNow ='no'
myPID = str(os.getpid())
print 'pid: ' + myPID
signal.signal(signal.SIGTERM, exit_func)
signal.signal(signal.SIGINT, exit_func)
retCode =theloop()
print ' in main program ' + quitNow
os.system('kill -9 ' + myPID)
## return (0)
## sys.exit()