From b78c842cf962120c5d346cbc76dc5a44f6e15652 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 29 Jun 2015 22:05:48 -0700 Subject: [PATCH] client: always show task_debug message if kill_program() fails ... but change kill_program() so it's not a failure if the process doesn't exit. This is to help debug a possible "zombie process" bug --- client/app_control.cpp | 29 +++++++++++++++-------------- lib/util.cpp | 5 ++++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/client/app_control.cpp b/client/app_control.cpp index 57442dd89b..d0f2c4388a 100644 --- a/client/app_control.cpp +++ b/client/app_control.cpp @@ -225,33 +225,34 @@ int ACTIVE_TASK::request_abort() { } #ifdef _WIN32 -static void kill_app_process(int pid, bool will_restart, bool show_errors) { +static void kill_app_process(int pid, bool will_restart) { int retval = 0; retval = kill_program(pid, will_restart?0:EXIT_ABORTED_BY_CLIENT); - if (retval && log_flags.task_debug && show_errors) { + if (retval && log_flags.task_debug) { msg_printf(0, MSG_INFO, - "[task] kill_app_process() failed: %s", - strerror(retval) + "[task] kill_program(%d) failed: %s", + pid, boincerror(retval) ); } } #else -static void kill_app_process(int pid, bool, bool show_errors) { +static void kill_app_process(int pid, bool) { int retval = 0; if (g_use_sandbox) { retval = kill_via_switcher(pid); - if (retval && log_flags.task_debug && show_errors) { + if (retval && log_flags.task_debug) { msg_printf(0, MSG_INFO, - "[task] kill_via_switcher() failed: %s (%d)", + "[task] kill_via_switcher(%d) failed: %s (%d)", + pid, (retval>=0) ? strerror(errno) : boincerror(retval), retval ); } } else { - retval = kill(pid, SIGKILL); - if (retval && log_flags.task_debug && show_errors) { + retval = kill_program(pid); + if (retval && log_flags.task_debug) { msg_printf(0, MSG_INFO, - "[task] kill() failed: %s", - strerror(errno) + "[task] kill_program(%d) failed: %s", + pid, strerror(errno) ); } } @@ -263,7 +264,7 @@ static void kill_app_process(int pid, bool, bool show_errors) { // will be cleaned up after it exits, by cleanup_task(); // int ACTIVE_TASK::kill_running_task(bool will_restart) { - kill_app_process(pid, will_restart, true); + kill_app_process(pid, will_restart); return 0; } @@ -277,10 +278,10 @@ int ACTIVE_TASK::kill_running_task(bool will_restart) { int ACTIVE_TASK::kill_subsidiary_processes() { unsigned int i; for (i=0; i