[#111712] [Ruby master Feature#19322] Support spawning "private" child processes — "kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core" <ruby-core@...>
SXNzdWUgIzE5MzIyIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGtqdHNhbmFrdHNpZGlzIChLSiBUc2Fu
14 messages
2023/01/07
[ruby-core:111790] Re: [Ruby master Feature#19322] Support spawning "private" child processes
From:
Eric Wong via ruby-core <ruby-core@...>
Date:
2023-01-12 00:10:42 UTC
List:
ruby-core #111790
"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. ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/