Is the process alive?
(pid: int)
| 20 | |
| 21 | |
| 22 | def alive(pid: int) -> bool: |
| 23 | """Is the process alive?""" |
| 24 | if sys.platform == "win32": |
| 25 | # why can't anything be easy... |
| 26 | status = DWORD() |
| 27 | handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid) |
| 28 | GetExitCodeProcess(handle, ctypes.byref(status)) |
| 29 | return status.value == 259 # STILL_ACTIVE |
| 30 | else: |
| 31 | try: |
| 32 | os.kill(pid, 0) |
| 33 | except OSError: |
| 34 | return False |
| 35 | return True |
| 36 | |
| 37 | |
| 38 | def kill(pid: int) -> None: |
no outgoing calls
no test coverage detected
searching dependent graphs…