boostorg / boostorg/process

Zombie process In Boost:: process::wait_until(wait_for_exit.hpp)

Open
#178 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
145
Forks
151
PR merge metrics
No merged PRs in 30d

Description

I have observed Z processes for MacOSX when we use Boost::Process::wait_until(), I see it on 1.73, but the offending code exists in 1.74 as well.

```
// child_cleaner is a class responsible for cleaning up the fork() used to simulate sigtimedwait()

struct child_cleaner_t
{
pid_t pid;
~child_cleaner_t()
{
int res;
::kill(pid, SIGKILL);
::waitpid(pid, &res, WNOHANG); <-- wait with WNOHANG can result in process leak as the kill is async
// for short-run cmd that terminate quickly there is a clear repro. If it were up to me, I would remove WNOHANG here as the child process will eventually terminate. or at least queue a wait in a cleanup thread.
}
};

```

Steps to repro:
```

const auto& cmdLine = boost::str(boost::format("/usr/bin/time"));
for(int i = 0; i <100; i++)
{
boost::process::child x(cmdLine, boost::process::std_out > boost::process::null, boost::process::std_err > boost::process::null);
x.wait_for(std::chrono::seconds{10});
}
```
I hope this is the best way to approach the community if you think I should talk to some DL or group elsewhere then do let me know.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.