Skip to content

Commit

Permalink
Propagate child process exit code properly
Browse files Browse the repository at this point in the history
Also when the child process was terminated by a signal.
  • Loading branch information
makortel committed Apr 26, 2024
1 parent b212c73 commit 6151d55
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions FWCore/PluginManager/bin/refresh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,13 @@ int main(int argc, char** argv) try {
// Throw if any of the child died with non 0 status.
int status = 0;
waitpid(worker, &status, 0);
if (WIFEXITED(status) == true && status != 0) {
std::cerr << "Error while processing." << std::endl;
exit(status);
if (WIFEXITED(status) != 0 and WEXITSTATUS(status) != 0) {
std::cerr << "Error in child process while processing: " << WEXITSTATUS(status) << std::endl;
exit(WEXITSTATUS(status));
}
if (WIFSIGNALED(status) != 0) {
std::cerr << "Child process got signal while processing: " << WTERMSIG(status) << std::endl;
exit(128 + WTERMSIG(status));
}
}
}
Expand Down

0 comments on commit 6151d55

Please sign in to comment.