fix(process): avoid leaking zombies and fds in detached processes (#3379)
This commit is contained in:
parent
54ddf37584
commit
1cab1a5a1e
3 changed files with 22 additions and 8 deletions
|
|
@ -269,6 +269,16 @@ namespace proc {
|
|||
|
||||
int
|
||||
proc_t::running() {
|
||||
#ifndef _WIN32
|
||||
// On POSIX OSes, we must periodically wait for our children to avoid
|
||||
// them becoming zombies. This must be synchronized carefully with
|
||||
// calls to bp::wait() and platf::process_group_running() which both
|
||||
// invoke waitpid() under the hood.
|
||||
auto reaper = util::fail_guard([]() {
|
||||
while (waitpid(-1, nullptr, WNOHANG) > 0);
|
||||
});
|
||||
#endif
|
||||
|
||||
if (placebo) {
|
||||
return _app_id;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue