Download dev/tests/web/fake/taskkill from mchuca/ServerMonitor: direct link, hf CLI and curl.
- Browser
- Download file 622 Bytes
-
https://huggingface.co/mchuca/ServerMonitor/resolve/main/dev/tests/web/fake/taskkill
- Command line
-
hf download hf://mchuca/ServerMonitor/dev/tests/web/fake/taskkill
-
curl -L -o taskkill https://huggingface.co/mchuca/ServerMonitor/resolve/main/dev/tests/web/fake/taskkill
622 Bytes
| #!/usr/bin/env python3 | |
| """Review stand-in for taskkill.exe: "taskkill /PID <n> /T /F" ends the process <n> and everything below it (like /T on Windows).""" | |
| import os, signal, sys | |
| args = sys.argv[1:] | |
| pid = int(args[args.index('/PID') + 1]) | |
| kids = {} | |
| for d in os.listdir('/proc'): | |
| if d.isdigit(): | |
| try: kids.setdefault(int(open(f'/proc/{d}/stat').read().rsplit(')', 1)[1].split()[1]), []).append(int(d)) | |
| except OSError: pass | |
| def tree(p): return [p] + [x for k in kids.get(p, []) for x in tree(k)] | |
| for p in tree(pid) if '/T' in args else [pid]: | |
| try: os.kill(p, signal.SIGKILL) | |
| except OSError: pass | |