MCPcopy Create free account
hub / github.com/FastLED/FastLED / is_process_alive

Function is_process_alive

ci/util/file_lock_rw_util.py:19–56  ·  view source on GitHub ↗

Check if a process with given PID is still running (cross-platform). Args: pid: Process ID to check Returns: True if process exists, False otherwise

(pid: int)

Source from the content-addressed store, hash-verified

17
18
19def is_process_alive(pid: int) -> bool:
20 """
21 Check if a process with given PID is still running (cross-platform).
22
23 Args:
24 pid: Process ID to check
25
26 Returns:
27 True if process exists, False otherwise
28 """
29 if pid <= 0:
30 return False
31
32 try:
33 # Unix/Linux/macOS: send signal 0 (doesn't actually send signal, just checks)
34 if platform.system() != "Windows":
35 os.kill(pid, 0)
36 return True
37 else:
38 # Windows: Try to open process handle
39 import ctypes
40
41 windll = getattr(ctypes, "windll")
42 kernel32 = windll.kernel32
43 PROCESS_QUERY_INFORMATION = 0x0400
44 handle = kernel32.OpenProcess(PROCESS_QUERY_INFORMATION, False, pid)
45 if handle:
46 kernel32.CloseHandle(handle)
47 return True
48 return False
49 except (OSError, ProcessLookupError):
50 return False
51 except KeyboardInterrupt as ki:
52 handle_keyboard_interrupt(ki)
53 raise
54 except Exception as e:
55 logger.warning(f"Error checking if PID {pid} is alive: {e}")
56 return False # Assume dead if we can't check

Callers 11

test_invalid_pid_deadMethod · 0.90
is_lock_staleMethod · 0.90
break_stale_lockMethod · 0.90
cleanup_stale_locksMethod · 0.90
_is_process_alive_psutilFunction · 0.90
list_active_locksFunction · 0.90
list_locksFunction · 0.90
check_lockFunction · 0.90

Calls 3

killMethod · 0.80
warningMethod · 0.80