import sysimport signalimport timeimport threading
def signalHandler(sig,id):
sys.exit()signal.signal(signal.SIGINT, signalHandler)signal.signal(signal.SIGQUIT, signalHandler)signal.signal(signal.SIGTERM, signalHandler)signal.signal(signal.SIGHUP, signalHandler)
class Test(threading.Thread):
def run(self): while True:
print 'xxxxxxxxxxx'
time.sleep(1)
def main():
t = Test()
t.start()
if __name__ == '__main__':
main()
import sysimport signalimport timeimport threading
NEEDEXIT = False
def signalHandler(sig,id):
global NEEDEXIT
NEEDEXIT = True
sys.exit()signal.signal(signal.SIGINT, signalHandler)signal.signal(signal.SIGQUIT, signalHandler)signal.signal(signal.SIGTERM, signalHandler)signal.signal(signal.SIGHUP, signalHandler)
class Test(threading.Thread):
def run(self):
global NEEDEXIT while not NEEDEXIT:
print 'xxxxxxxxxxx'
time.sleep(1)
def main():
t = Test()
t.start()
if __name__ == '__main__':
main()