X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fos_posix.cpp;h=7d39d8ada5e0ffafc0f730bcdd3e913744f734d2;hb=41a6d89aa0156103f5217521fe582941782aad8e;hp=261fe88c929409d796b8cbd82ed6ea574dfc9990;hpb=ddbf8c0065ce1b7502e3e127a846add476ab7a4c;p=apitrace diff --git a/common/os_posix.cpp b/common/os_posix.cpp index 261fe88..7d39d8a 100644 --- a/common/os_posix.cpp +++ b/common/os_posix.cpp @@ -44,6 +44,10 @@ #include #endif +#ifdef ANDROID +#include +#endif + #ifndef PATH_MAX #warning PATH_MAX undefined #define PATH_MAX 4096 @@ -139,8 +143,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; } } @@ -153,11 +166,19 @@ log(const char *format, ...) va_list ap; va_start(ap, format); fflush(stdout); +#ifdef ANDROID + __android_log_vprint(ANDROID_LOG_DEBUG, "apitrace", format, ap); +#else vfprintf(stderr, format, ap); +#endif va_end(ap); logging = false; } +#if defined(__APPLE__) +long long timeFrequency = 0LL; +#endif + void abort(void) {