You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
648B

  1. import py
  2. import os, sys
  3. if sys.platform == "win32" or getattr(os, '_name', '') == 'nt':
  4. try:
  5. import ctypes
  6. except ImportError:
  7. def dokill(pid):
  8. py.process.cmdexec("taskkill /F /PID %d" %(pid,))
  9. else:
  10. def dokill(pid):
  11. PROCESS_TERMINATE = 1
  12. handle = ctypes.windll.kernel32.OpenProcess(
  13. PROCESS_TERMINATE, False, pid)
  14. ctypes.windll.kernel32.TerminateProcess(handle, -1)
  15. ctypes.windll.kernel32.CloseHandle(handle)
  16. else:
  17. def dokill(pid):
  18. os.kill(pid, 15)
  19. def kill(pid):
  20. """ kill process by id. """
  21. dokill(pid)