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

Function process_exists

ci/docker_utils/container_db.py:345–368  ·  view source on GitHub ↗

Check if a process with given PID is running. Args: pid: Process ID to check Returns: True if process exists, False otherwise

(pid: int)

Source from the content-addressed store, hash-verified

343
344
345def process_exists(pid: int) -> bool:
346 """Check if a process with given PID is running.
347
348 Args:
349 pid: Process ID to check
350
351 Returns:
352 True if process exists, False otherwise
353 """
354 try:
355 # os.kill with signal 0 doesn't actually kill the process,
356 # it just checks if we can send a signal to it
357 os.kill(pid, 0)
358 return True
359 except ProcessLookupError:
360 return False
361 except PermissionError:
362 # Process exists but we don't have permission to signal it
363 return True
364 except KeyboardInterrupt as ki:
365 handle_keyboard_interrupt(ki)
366 raise
367 except Exception:
368 return False
369
370
371def docker_container_exists(container_name: str) -> Optional[str]:

Callers 4

test_orphan_detectionFunction · 0.90
test_process_existsFunction · 0.90
prepare_containerFunction · 0.85

Calls 2

killMethod · 0.80

Tested by 2

test_orphan_detectionFunction · 0.72
test_process_existsFunction · 0.72