mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-10 05:01:28 -10:00
* test(daemon): stop what a worker left running after it was reaped A daemon worker is launched into its own process group, but Kill and the Cancel hook pass its PID to background.TerminateProcess, which looks the group up again with Getpgid when it signals. Once the worker has exited and been waited, that lookup fails, only the dead PID is signalled, and a child the worker left running survives. This pins the case with a shell worker that backgrounds a sleep and exits: after the wait, Kill and the Cancel hook must still stop the sleep. Committed ahead of the fix so CI shows it failing on the current behaviour on Linux and macOS. * fix(daemon): stop worker process groups by their launch-time identity Kill and the Cancel hook now go through background.TerminateCommandGroup, which signals the group the worker was launched into (ConfigureChild- ProcessGroup's Setpgid) instead of rediscovering it from the PID, so a worker that has exited, or on Darwin one that is still a zombie, no longer leaves its children running. It is TerminateCommand without the reap: the pool waits on its workers itself and exec.Cmd calls Cancel from inside Wait, so reaping there would be a second Wait. On Windows it is the same tree kill, with the process handle pinned while it runs. A command that has already been waited cannot be pinned; that now reports os.ErrProcessDone, which exec.Cmd's Cancel contract treats as nothing to cancel, instead of the unexported "already released" error. Fixes #861