Expand description
The processes below one process, read before it is stopped and signalled only while they are still the ones found.
What:
The processes below one process: found before it is stopped, and signalled afterwards, each only while it is still
the process that was found.
Why:
Stopping a process does not stop what it started. A git push that is sent SIGTERM or SIGKILL leaves its
transport helper (git-remote-http, ssh) and the hooks it ran (git-lfs) alive, orphaned to the init process,
holding their connection until their own timeout ends them (measured: a helper stayed 60 seconds, a git-lfs
that never exits stayed for good). The tree has to be read before the root dies, because a child’s link to its
parent is gone once the parent has exited. A process number can be reused, so each process is identified by the
start time the kernel recorded for it, and a number whose start time changed is not signalled.
The list comes from /proc, so only Linux finds any; elsewhere the tree is empty and only the root is stopped.
In TS you’d write (pseudocode):
const tree = await descendantsOf(child.pid); child.kill('SIGTERM'); for (const process of tree) process.signalIfSame('SIGTERM');Structs§
- Tree
Member - One process of a tree and the start time that proves it is still that process.
Functions§
- descendants_
of - What:
Every living process below
root, children before grandchildren, with their start times. Why: Read once, before the root is signalled, from one pass over/proc. - kill_
members - End each member that is still the process that was found, with
SIGKILL. - signal_
members - What:
Send
signalto each member that is still the process that was found; the others are left alone. Why: A number that was reused by an unrelated process must never be signalled. - still_
running - Whether the process is still the one that was found: it exists, is not a zombie, and has the recorded start time.
- terminate_
members - Ask each member that is still the process that was found to end, with
SIGTERM.