sheredom / subprocess.h

🐜 single header process launching solution for C and C++
The Unlicense
1.12k stars 97 forks source link

can subprocess_join tell if the process failed? #17

Closed pthom closed 4 years ago

pthom commented 4 years ago

Hello,

Thanks for this useful library! I encountered a problem when calling subprocess_join: it cannot detect whether the process failed.

The following lines taken from the code show the reason:

  if (out_return_code) {
    if (WIFEXITED(status)) {
      *out_return_code = WEXITSTATUS(status);
    } else {
      *out_return_code = 0  // process did not exit normally, but we return 0 as exit status, anyway (!)
    }
  }

Is there another way to check for process failures?

Thanks!

sheredom commented 4 years ago

Hey @pthom! Yeah that looks like a bug.

Do you have any small repro case for a process that doesn't exit 'normally'? I'm honestly not that sure how you can even get there (segfault or something?).

sheredom commented 4 years ago

Fixed by @pthom - thanks!