Force-terminate `pid` and its whole tree; True only on proven success. A tool that cannot start, cannot finish within its own budget, or reports failure is never read as success -- the caller refuses to call the tree clean.
(pid: int)
| 258 | |
| 259 | |
| 260 | def windows_taskkill_tree(pid: int) -> bool: |
| 261 | """Force-terminate `pid` and its whole tree; True only on proven success. |
| 262 | |
| 263 | A tool that cannot start, cannot finish within its own budget, or reports |
| 264 | failure is never read as success -- the caller refuses to call the tree |
| 265 | clean. |
| 266 | """ |
| 267 | try: |
| 268 | completed = subprocess.run( |
| 269 | ["taskkill.exe", "/PID", str(pid), "/T", "/F"], |
| 270 | check=False, |
| 271 | stdin=subprocess.DEVNULL, |
| 272 | stdout=subprocess.DEVNULL, |
| 273 | stderr=subprocess.DEVNULL, |
| 274 | timeout=WINDOWS_TASKKILL_SECONDS, |
| 275 | ) |
| 276 | except (OSError, subprocess.TimeoutExpired): |
| 277 | return False |
| 278 | return completed.returncode == 0 |
| 279 | |
| 280 | |
| 281 | def terminate_process_tree(active: ActiveSuite, kill_grace: int) -> None: |
no test coverage detected