ProcessLookupError
PythonERRORNotableOS ErrorHIGH confidence
Process not found
Production Risk
Common in process management code; always handle the case that a PID may no longer exist.
What this means
A subclass of OSError (errno ESRCH) raised when a process cannot be found — typically when sending a signal to a PID that no longer exists.
Why it happens
- 1os.kill() called with a PID that has already exited
- 2Race condition: process exited between PID lookup and signal send
How to reproduce
Sending a signal to a process that has already exited.
trigger — this will error
trigger — this will error
import os os.kill(99999, 0) # PID 99999 does not exist
expected output
ProcessLookupError: [Errno 3] No such process
Fix
Catch ProcessLookupError when signaling processes
WHEN Sending signals to externally managed processes
Catch ProcessLookupError when signaling processes
import os
def is_running(pid):
try:
os.kill(pid, 0) # Signal 0 checks existence without killing
return True
except ProcessLookupError:
return False
except PermissionError:
return True # Process exists but we lack permissionWhy this works
os.kill(pid, 0) is the standard way to check if a process exists; signal 0 does not kill.
Code examples
Triggerpython
import os os.kill(99999, 0) # ProcessLookupError: No such process
Handle with try/exceptpython
import os
try:
os.kill(pid, 0)
except ProcessLookupError:
print(f"Process {pid} no longer exists")Avoid by using signal 0 for existence checkpython
def is_running(pid):
try:
os.kill(pid, 0)
return True
except (ProcessLookupError, PermissionError):
return FalseSame error in other languages
Sources
Official documentation ↗
Python Docs — Built-in Exceptions
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev