
"Eregon (Benoit Daloze) via ruby-core" <ruby-core@ml.ruby-lang.org> wrote:
IMHO this sounds like some code is doing bad stuff and not properly caring about its own resources.
In the example you shown, I believe it's none of Unicorn's business to reap arbitrary processes, it doesn't compose (I could be wrong, but this seems a general rule when it come to resources of a program: don't mess with what you don't own). Unicorn should keep a list of pid subprocesses it created, and only do something on the `Signal.trap(:CHLD) do` if it's one of these pids.
There'd be lots of zombies if unicorn did what you propose (at least for non-MJIT-Rubies). KJ: do you need to care about the exit status? Or just whether or not a process has exited? If it's only the latter, turning FD_CLOEXEC off on the write end of a pipe would let you IO.select/poll/epoll_wait on the read end to detect when the child+descendents are all dead: r, w = IO.pipe Process.spawn ..., w => w # share `w' with all descendents w.close IO.select([r, ...], ...) I've started using the above pattern in tests for setsid daemons lately.