Get the process tree (parents) for a process.
(proc: psutil.Process)
| 32 | |
| 33 | |
| 34 | def get_process_tree(proc: psutil.Process) -> list[psutil.Process]: |
| 35 | """Get the process tree (parents) for a process.""" |
| 36 | tree: list[psutil.Process] = [] |
| 37 | current = proc |
| 38 | try: |
| 39 | while current: |
| 40 | tree.append(current) |
| 41 | current = current.parent() |
| 42 | except (psutil.NoSuchProcess, psutil.AccessDenied): |
| 43 | pass |
| 44 | return tree |
| 45 | |
| 46 | |
| 47 | def check_matches_kill_patterns( |