diff --git a/client/app_control.cpp b/client/app_control.cpp index e9aa5d76ff..4d0faa0a61 100644 --- a/client/app_control.cpp +++ b/client/app_control.cpp @@ -224,7 +224,7 @@ static void kill_app_process(int pid, bool) { if (retval && log_flags.task_debug) { msg_printf(0, MSG_INFO, "[task] kill_via_switcher() failed: %s", - boincerror(retval) + (retval==-1) ? strerror(errno) : boincerror(retval) ); } #endif @@ -232,7 +232,7 @@ static void kill_app_process(int pid, bool) { if (retval && log_flags.task_debug) { msg_printf(0, MSG_INFO, "[task] kill() failed: %s", - boincerror(retval) + (retval==-1) ? strerror(errno) : boincerror(retval) ); } } @@ -269,6 +269,7 @@ int ACTIVE_TASK::kill_running_task(bool will_restart) { int ACTIVE_TASK::kill_exited_task() { kill_processes(other_pids, true); kill_processes(descendants, true); + return 0; } // We have sent a quit request to the process; see if it's exited. diff --git a/client/sandbox.cpp b/client/sandbox.cpp index ff6ff93a23..776726eca8 100644 --- a/client/sandbox.cpp +++ b/client/sandbox.cpp @@ -95,6 +95,7 @@ int set_to_project_group(const char* path) { int switcher_exec(const char *util_filename, const char* cmdline) { char* argv[100]; char util_path[MAXPATHLEN]; + int stat; sprintf(util_path, "%s/%s", SWITCHER_DIR, util_filename); argv[0] = const_cast(util_filename); @@ -111,7 +112,12 @@ int switcher_exec(const char *util_filename, const char* cmdline) { return ERR_EXEC; } // Wait for command to complete, like system() does. - waitpid(pid, 0, 0); + waitpid(pid, &stat, 0); + + if (WIFEXITED(stat)) { + return WEXITSTATUS(stat); + } + return 0; } diff --git a/client/switcher.cpp b/client/switcher.cpp index 7bc1aa84f0..3200ed62dc 100644 --- a/client/switcher.cpp +++ b/client/switcher.cpp @@ -130,9 +130,13 @@ int main(int /*argc*/, char** argv) { #endif } - execv(argv[1], argv+2); + retval = execv(argv[1], argv+2); + if (retval == -1) { + retval = errno; - // If we got here execv failed - fprintf(stderr, "Process creation (%s) failed: errno=%d\n", argv[1], errno); + // If we got here execv failed + fprintf(stderr, "Process creation (%s) failed: %s (errno = %d)\n", argv[1], strerror(retval), retval); + } + return retval; }