当前进程执行到指定位置时,使用signal.SIGKILL自动结束进程
#!/usr/bin/env python import time import os import signal def main(): print "start process" os.kill(os.getpid(),signal.SIGKILL) time.sleep(60) print "end process" if __name__ == '__main__': main()
执行结果:
start process Killed