Files
rizin/test/scripts/kill_http_server.py
T
Khairul Azhar Kasmiran 460a9f51e6 Run http test on Windows (#6839)
* Run http test on Windows
* Install `psutil` whenever `requests` is installed
* Use `psutil` 6.1.1 on CentOS 7
* Install `python3-devel` on CentOS 7
* Install `py3-psutil` on Alpine
* Use `Python314-x64` in `clang_cl_64_dyn` build
2026-10-06 19:37:30 +08:00

31 lines
750 B
Python
Executable File

#!/usr/bin/env python3
r"""
This script kills the http.server launched by http_server.py.
"""
import re
import sys
import psutil
http_server_killed = 0
for p in psutil.process_iter(["cmdline"]):
try:
if re.search(r"[Pp]ythonw?3? -m http\.server 9000", " ".join(p.cmdline())):
p.kill()
http_server_killed += 1
if http_server_killed == 2:
# Not stopping at 1 since what got killed might have been the
# shell that ran the server
break
except (psutil.AccessDenied, psutil.NoSuchProcess):
pass
if http_server_killed > 0:
print("Killed http.server")
sys.exit(0)
else:
print("ERROR: http.server process not found")
sys.exit(1)