osaf/services/infrastructure/nid/nodeinit.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/osaf/services/infrastructure/nid/nodeinit.c b/osaf/services/infrastructure/nid/nodeinit.c --- a/osaf/services/infrastructure/nid/nodeinit.c +++ b/osaf/services/infrastructure/nid/nodeinit.c @@ -1108,6 +1108,30 @@ void cleanup(NID_SPAWN_INFO *service) nid_close_ipc(); select_fd = -1; + pid_t w_pid; + int status; + uint32_t no_of_retries = 0; + const uint32_t MAX_NO_RETRIES = 5; + + if (check_process(service)) { + // send abort signal to process to generate a core dump + LOG_ER("Sending SIGABRT to %s, pid=%d", service->serv_name, service->pid); + if (kill(service->pid, SIGABRT) >= 0) { + // wait a short period for process to exit + do { + w_pid = waitpid(service->pid, &status, WNOHANG); + if (w_pid < 0) { + break; + } else { + if (!WIFEXITED(status) && !WIFSIGNALED(status)) { + sleep(1); + } + } + } while (!WIFEXITED(status) && !WIFSIGNALED(status) && ++no_of_retries < MAX_NO_RETRIES); + } + } + + // if sending abort signal did not succeed, fallback to sigkill if (check_process(service)) { LOG_ER("Sending SIGKILL to %s, pid=%d", service->serv_name, service->pid); kill(service->pid, SIGKILL); ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel