perpetuo icon indicating copy to clipboard operation
perpetuo copied to clipboard

Add PR_SET_PDEATHSIG to ensure watcher process terminates when parent dies

Open abstrctn opened this issue 1 year ago • 1 comments

This change ensures that on Linux systems, if the parent Python process dies unexpectedly, the kernel will automatically send SIGTERM to the watcher process, preventing it from becoming a zombie process.

abstrctn avatar Dec 10 '24 18:12 abstrctn

SIGTERM doesn't prevent processes from becoming zombies. The Unix process model is counterintuitive, though it has an internal logic. The point of a zombie process is that whenever a process exits, the kernel keeps the PID reserved (to prevent race conditions) and keeps a bit of memory to hold the exit status, until the parent process "reaps" the zombie = tells the kernel that it's OK to forget about the exit status and re-allocate the PID to a new process. So every way of process exiting always creates a zombie; they always have to be reaped.

Is it actually zombie processes that are causing problems? Or is perpetuo failing to exit in the first place?

njsmith avatar Dec 14 '24 03:12 njsmith