> pkill(1), killall(1) and killall5(8) all retrieve a process list and > kill them one by one, instead of calling kill(-1, signal), so a race > condition can happen thats let some process escape the final SIGKILL.
interesting. i have not considered this at all. looks like kill( -1, sig ) from process #1 ensures correctnes here in a cheap and simple way. so splitting stage 3 into 2 parts seems to be a good approach. > Since pkill(1) and killall(1) use regex matching, the probability for > the race can be significantly larger. since they do more work to select processes and hence need more time when iterating the PID dirs in the procfs ? though i doubt they use any matching at all when tasked with killing all processes and probably behave like the killall5 utility in this situation. OpenRC also provides a tool for that task btw: /libexec/rc/bin/kill_all it uses the kvm method to find running processes on the BSDs and the procfs on Linux.
