From 33bf4f78515cb4b92ad99e4f5c4fd8e178adc608 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 10 Apr 2013 15:56:40 -0700 Subject: [PATCH] - client: check error returns from kill() and kill_via_switcher(), show messages --- client/app_control.cpp | 16 ++++++++++++++-- client/sandbox.cpp | 8 ++++---- client/sandbox.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/client/app_control.cpp b/client/app_control.cpp index 72ba21f3d0..8bd7ff1051 100644 --- a/client/app_control.cpp +++ b/client/app_control.cpp @@ -215,9 +215,21 @@ static void kill_app_process(int pid, bool will_restart) { #else static void kill_app_process(int pid, bool) { #ifdef SANDBOX - kill_via_switcher(pid); + int retval = kill_via_switcher(pid); + if (retval && log_flags.task_debug) { + msg_printf(0, MSG_INFO, + "[task] kill_via_switcher() failed: %s", + boincerror(retval) + ); + } #endif - kill(pid, SIGKILL); + int retval = kill(pid, SIGKILL); + if (retval && log_flags.task_debug) { + msg_printf(0, MSG_INFO, + "[task] kill() failed: %s", + boincerror(retval) + ); + } #endif } diff --git a/client/sandbox.cpp b/client/sandbox.cpp index 68e917fe95..ff6ff93a23 100644 --- a/client/sandbox.cpp +++ b/client/sandbox.cpp @@ -51,17 +51,17 @@ static int lookup_group(const char* name, gid_t& gid) { } #endif -void kill_via_switcher(int pid) { +int kill_via_switcher(int pid) { char cmd[1024]; - if (!g_use_sandbox) return; + if (!g_use_sandbox) return 0; // if project application is running as user boinc_project and // client is running as user boinc_master, // we cannot send a signal directly, so use switcher. // sprintf(cmd, "/bin/kill kill -s KILL %d", pid); - switcher_exec(SWITCHER_FILE_NAME, cmd); + return switcher_exec(SWITCHER_FILE_NAME, cmd); } int get_project_gid() { @@ -112,7 +112,7 @@ int switcher_exec(const char *util_filename, const char* cmdline) { } // Wait for command to complete, like system() does. waitpid(pid, 0, 0); - return BOINC_SUCCESS; + return 0; } int remove_project_owned_file_or_dir(const char* path) { diff --git a/client/sandbox.h b/client/sandbox.h index d8266bbc4f..e123985fd3 100644 --- a/client/sandbox.h +++ b/client/sandbox.h @@ -15,7 +15,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -extern void kill_via_switcher(int pid); +extern int kill_via_switcher(int pid); extern int get_project_gid(); extern int set_to_project_group(const char* path); extern int switcher_exec(const char* util_filename, const char* cmdline);