X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fos_posix.cpp;h=0d93b31bcafa6e56604fa639a7656d20128835ca;hb=bd4937e47675d600b13174773dc05ab1129c266b;hp=ebd59a097076d05fe6b3eadf4c2ffae57a78547d;hpb=ee659c84695e9f94b1f6a5f8be203dc0012ca685;p=apitrace diff --git a/common/os_posix.cpp b/common/os_posix.cpp index ebd59a0..0d93b31 100644 --- a/common/os_posix.cpp +++ b/common/os_posix.cpp @@ -134,7 +134,11 @@ int execute(char * const * args) if (pid == 0) { // child execvp(args[0], args); - fprintf(stderr, "error: failed to execute %s\n", args[0]); + fprintf(stderr, "error: failed to execute:"); + for (unsigned i = 0; args[i]; ++i) { + fprintf(stderr, " %s", args[i]); + } + fprintf(stderr, "\n"); exit(-1); } else { // parent @@ -143,8 +147,17 @@ int execute(char * const * args) return -1; } int status = -1; + int ret; waitpid(pid, &status, 0); - return status; + if (WIFEXITED(status)) { + ret = WEXITSTATUS(status); + } else if (WIFSIGNALED(status)) { + // match shell return code + ret = WTERMSIG(status) + 128; + } else { + ret = 128; + } + return ret; } }