cpp-subprocess icon indicating copy to clipboard operation
cpp-subprocess copied to clipboard

Popen fails to return error code in shell mode

Open klosworks opened this issue 5 years ago • 0 comments

I would expect this code:

    using namespace subprocess;
    auto proc = Popen("ls fdklajfdlsajfdkljaf", error{PIPE}, cwd{where}, shell{true});
    auto errors = proc.communicate().first;
    std::cerr << errors.buf.data() << std::endl;
    int exit_code = proc.wait();
    if(exit_code != 0)
    {
        cerr << "the command " << command << " returned error code " << exit_code << endl;
        exit(1);
    }

to set the exit_code variable to 2 and exit. Instead it sets it to 0 and goes on.

klosworks avatar Jul 03 '19 09:07 klosworks