boostorg / boostorg/process

Error in tutorial (double wait) and/or possible bug ("wait error: No child processes")

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

Description

I'm not sure if this is the right project for documentation issues. But here:
https://www.boost.org/doc/libs/1_75_0/doc/html/boost_process/tutorial.html#boost_process.tutorial.group

It gives the following example
```
bp::group g;
bp::child c("make", g);
if (!g.wait_for(std::chrono::seconds(10))
g.terminate();

c.wait(); //to avoid a zombie process & get the exit code
```

However this results in a runtime error in case of a successful wait:
```
terminating with uncaught exception of type boost::process::process_error: wait error: No child processes
```
I think the correct code snippet should be:
```
bp::group g;
bp::child c("make", g);
if (!g.wait_for(std::chrono::seconds(10))
{
g.terminate();
c.wait(); //to avoid a zombie process & get the exit code
}
```

Edit: I found a weird case. If I call `c.running()` before `c.wait()` in the crashing snippet then I do not get the exception. I think somehow the `running` call affects the internal state which the name suggests it shouldn't (even though the signature is not `const`).

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.