MCPcopy Create free account
hub / github.com/python/mypy / alive

Function alive

mypy/dmypy_os.py:22–35  ·  view source on GitHub ↗

Is the process alive?

(pid: int)

Source from the content-addressed store, hash-verified

20
21
22def 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
38def kill(pid: int) -> None:

Callers 1

check_statusFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…