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.

15 lines
330 B

  1. import sys
  2. import os
  3. import signal
  4. if sys.platform.startswith("win"):
  5. def taskkill(pid):
  6. os.system('taskkill /F /PID {:d} /T >NUL 2>NUL'.format(pid))
  7. else: # POSIX
  8. import psutil
  9. def taskkill(pid):
  10. parent = psutil.Process(pid)
  11. for child in parent.children(recursive=True):
  12. child.kill()
  13. parent.kill()