def testKillILL(self): """Test of a forced shutdown od a Twisted process. """ handle = os.spawnv(os.P_NOWAIT, self.bin, [self.bin, "twisted_process.py"]) time.sleep(1) # XXX give time to reactor to start pid = toolhelp32.GetProcessId(handle) kill32.kill(pid, signal.SIGILL) os.waitpid(handle, os.P_WAIT) lines = file(".out").readlines() self.failIf("shutdown\n" in lines) self.failIf("timeout\n" in lines) os.remove(".out")
def testKillTERMPython(self): """Test of a clean shutdown of a Python process. """ handle = os.spawnv(os.P_NOWAIT, self.bin, [self.bin, "python_process.py"]) time.sleep(1) # XXX give time to process to start pid = toolhelp32.GetProcessId(handle) kill32.kill(pid, signal.SIGTERM) os.waitpid(handle, os.P_WAIT) lines = file(".out").readlines() self.failUnless("signal handler\n" in lines) self.failUnless("atexit\n" in lines) os.remove(".out")
sys.exit(0) if o == "-h": sys.stdout.write(__doc__) sys.exit(0) elif o == "-s": sig = a # XXX TODO -t if len(args) == 0: sys.stdout.write(__doc__) sys.exit(2) try: pid = int(args[0]) except ValueError: print "invalid pid" sys.exit(2) if sig is None: sig = signal.SIGTERM else: if sig.isdigit(): sig = int(sig) else: try: sig = signals[sig] except KeyError: print "invalid signal", sig kill(pid, sig)
elif o == "-s": sig = a # XXX TODO -t if len(args) == 0: sys.stdout.write(__doc__) sys.exit(2) try: pid = int(args[0]) except ValueError: print "invalid pid" sys.exit(2) if sig is None: sig = signal.SIGTERM else: if sig.isdigit(): sig = int(sig) else: try: sig = signals[sig] except KeyError: print "invalid signal", sig kill(pid, sig)