- client: check error returns from kill() and kill_via_switcher(), show messages

This commit is contained in:
David Anderson 2013-04-10 15:56:40 -07:00
parent 6149911589
commit 33bf4f7851
3 changed files with 19 additions and 7 deletions

View File

@ -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
}

View File

@ -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) {

View File

@ -15,7 +15,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
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);