ESRCH
Linux / POSIXERRORNotableProcessHIGH confidence
No Such Process
What this means
The specified process ID does not correspond to any running process. The process may have terminated between when its PID was obtained and when the operation was attempted, which is a classic TOCTOU race condition.
Why it happens
- 1The process exited before the kill or waitpid call was made.
- 2A PID was stored and the process finished, but the PID was reused by a different process.
- 3The PID number was computed incorrectly or read from a stale PID file.
How to reproduce
Sending a signal to a process that has already exited.
trigger — this will error
trigger — this will error
$ kill -9 99999 bash: kill: (99999) - No such process
expected output
bash: kill: (99999) - No such process $ echo $? 1
Fix
Check process existence before signaling
WHEN When managing long-running background processes
Check process existence before signaling
$ kill -0 $PID 2>/dev/null && echo running || echo gone
Why this works
kill -0 sends no actual signal but checks whether the process exists and you have permission to signal it.
Sources
Official documentation ↗
Linux Programmer Manual errno(3)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev