| 5620 | if check_subprocesses in ("kill_subprocesses", "dont_kill_subprocesses", "kill_subprocesses_ignore_pid"): |
| 5621 | |
| 5622 | def is_pid_alive(pid): |
| 5623 | # Note: the process may be a zombie process in Linux |
| 5624 | # (althought it's killed it remains in that state |
| 5625 | # because we're monitoring it). |
| 5626 | try: |
| 5627 | proc = psutil.Process(pid) |
| 5628 | if proc.status() == psutil.STATUS_ZOMBIE: |
| 5629 | return False |
| 5630 | except psutil.NoSuchProcess: |
| 5631 | return False |
| 5632 | return True |
| 5633 | |
| 5634 | def get_live_pids(): |
| 5635 | return [pid for pid in process_ids_to_check if is_pid_alive(pid)] |