pclose() returns -1 only in specific cases, otherwise it returns the
exit status of the child, to be retrieved by the macro WEXITSTATUS.
This commit is contained in:
Enrico Forestieri 2022-12-11 12:15:37 +01:00
parent b278d5ac73
commit d7910e1870

View File

@ -1148,10 +1148,10 @@ cmd_ret const runCommand(string const & cmd)
valid = false;
#elif defined (HAVE_PCLOSE)
int const pret = pclose(inf);
bool const valid = (pret != -1);
bool const valid = (WEXITSTATUS(pret) == 0);
#elif defined (HAVE__PCLOSE)
int const pret = _pclose(inf);
bool const valid = (pret != -1);
bool const valid = (WEXITSTATUS(pret) == 0);
#else
#error No pclose() function.
#endif