What should be a return code of a terminated process? I run "bash -c \"while true; do true; done\""
and call terminate
. In boost 1.65 it was 0
, now in boost 1.71 it is 383
.
Asked
Active
Viewed 573 times
1

Yakk - Adam Nevraumont
- 262,606
- 27
- 330
- 524

Yuki
- 3,857
- 5
- 25
- 43
-
`terminate` is documented to only signal the child process, I assume that the return code depends on what that process does. – Quentin Feb 03 '21 at 12:32
1 Answers
1
The documentation of exit_code()
states:
The return value is without any meaning if the child wasn't waited for or if it was terminated.
So it seems exit_code()
isn't supposed to be called if the process is terminate
d.
On Linux, an "exit code" of 383
(0x17F
) means the process is still running. So it's worth trying to wait
for the process to finish before fetching its exit code.
There were a few changes in Boost.Process somewhere around version 1.71 which could explain the difference in behavior (for example, changed SIGTERM to SIGKILL), but according to exit_code
documentation it was never OK to call it in combination with terminate
.

rustyx
- 80,671
- 25
- 200
- 267
-
Interesting, I do have a `wait` call. I just don't understand how can you get an exit code if the process is still running. One just excludes the other right? – Yuki Feb 03 '21 at 15:20
-
See my updates. `exit_code()` is probably just a wrapper around `waitpid(... WNOHANG)`, which returns the exit *status*, which *may* contain an exit code. – rustyx Feb 03 '21 at 15:51
-
See also https://stackoverflow.com/questions/57732569/cant-get-segmentation-fault-exit-code-from-boost-child-process/57733210#57733210 – sehe Feb 03 '21 at 20:18