c++boostboost-process

Boost Process exit code of terminated process


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.


Solution

  • 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 terminated.

    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.