diff --git a/src/core/lib/support/subprocess_posix.c b/src/core/lib/support/subprocess_posix.c index 4f4de9298e9c38d552c8db78b3393bd739d28323..daf371d03eee45b8f02a32a93336eef8a2d72127 100644 --- a/src/core/lib/support/subprocess_posix.c +++ b/src/core/lib/support/subprocess_posix.c @@ -40,6 +40,7 @@ #include <assert.h> #include <errno.h> #include <signal.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -52,7 +53,7 @@ struct gpr_subprocess { int pid; - int joined; + bool joined; }; const char *gpr_subprocess_binary_extension() { return ""; } @@ -100,6 +101,7 @@ retry: gpr_log(GPR_ERROR, "waitpid failed: %s", strerror(errno)); return -1; } + p->joined = true; return status; } diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index 74e40fbf1a9b36283d588ed164812662af58a828..106509ab83e9e82fcaaf570064cc68304ff72511 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -50,6 +50,18 @@ std::string as_string(const T& val) { return out.str(); } +static void LogStatus(int status, const char* label) { + if (WIFEXITED(status)) { + gpr_log(GPR_INFO, "%s: subprocess exited with status %d", label, + WEXITSTATUS(status)); + } else if (WIFSIGNALED(status)) { + gpr_log(GPR_INFO, "%s: subprocess terminated with signal %d", label, + WTERMSIG(status)); + } else { + gpr_log(GPR_INFO, "%s: unknown subprocess status: %d", label, status); + } +} + int main(int argc, char** argv) { typedef std::unique_ptr<SubProcess> SubProcessPtr; std::vector<SubProcessPtr> jobs; @@ -75,12 +87,18 @@ int main(int argc, char** argv) { for (int i = 1; i < argc; i++) { args.push_back(argv[i]); } - GPR_ASSERT(SubProcess(args).Join() == 0); + int status = SubProcess(args).Join(); + if (status != 0) { + LogStatus(status, "driver"); + } for (auto it = jobs.begin(); it != jobs.end(); ++it) { (*it)->Interrupt(); } for (auto it = jobs.begin(); it != jobs.end(); ++it) { - (*it)->Join(); + status = (*it)->Join(); + if (status != 0) { + LogStatus(status, "worker"); + } } }