From 12b77984216a0a0a0bdef32f7bf7dc3f5422cb28 Mon Sep 17 00:00:00 2001 From: Kazunori INOUE Date: Thu, 1 Aug 2013 17:04:23 +0900 Subject: [PATCH] Fix: Fencing: Prevent sending SIGTERM to stonithd when stointh operation timed out --- fencing/fence_legacy | 8 +------- fencing/fence_pcmk | 8 +------- lib/fencing/st_client.c | 6 +++--- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/fencing/fence_legacy b/fencing/fence_legacy index c48ed24930e..d08e8a67d53 100755 --- a/fencing/fence_legacy +++ b/fencing/fence_legacy @@ -190,12 +190,7 @@ $opt_o=lc($opt_o); fail "failed: unrecognised action: $opt_o" unless $opt_o =~ /^(on|off|reset|reboot|stat|status|monitor|list|hostlist|poweroff|poweron)$/; -sub term_handler { - local $SIG{TERM} = 'IGNORE'; - kill(TERM,-getpgrp($$)); -} - -setpgrp($$,0); +setpgrp(0,0); if ( $pid=fork() == 0 ) { @@ -229,7 +224,6 @@ if ( $pid=fork() == 0 ) } } -$SIG{TERM} = \&term_handler; wait; $status=$?/256; diff --git a/fencing/fence_pcmk b/fencing/fence_pcmk index 51c56467c24..e66c20ba5e0 100755 --- a/fencing/fence_pcmk +++ b/fencing/fence_pcmk @@ -182,12 +182,7 @@ $opt_o=lc($opt_o); fail "failed: unrecognised action: $opt_o" unless $opt_o =~ /^(on|off|reset|reboot|stat|status|monitor|list|hostlist|poweroff|poweron)$/; -sub term_handler { - local $SIG{TERM} = 'IGNORE'; - kill(TERM,-getpgrp($$)); -} - -setpgrp($$,0); +setpgrp(0,0); $agent_pid=$$; if ( $pid=fork() == 0 ) @@ -210,7 +205,6 @@ if ( $pid=fork() == 0 ) exec "stonith_admin $cmd $opt_n --tolerance 5s --tag cman" or die "failed to exec \"stonith_admin $cmd $opt_n\"\n"; } -$SIG{TERM} = \&term_handler; wait; $status=$?/256; diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c index 3c6a7e714bd..f1d44565562 100644 --- a/lib/fencing/st_client.c +++ b/lib/fencing/st_client.c @@ -506,7 +506,7 @@ st_child_term(gpointer data) crm_info("Child %d timed out, sending SIGTERM", track->pid); track->timer_sigterm = 0; track->last_timeout_signo = SIGTERM; - rc = kill(track->pid, SIGTERM); + rc = kill(-track->pid, SIGTERM); if (rc < 0) { crm_perror(LOG_ERR, "Couldn't send SIGTERM to %d", track->pid); } @@ -522,7 +522,7 @@ st_child_kill(gpointer data) crm_info("Child %d timed out, sending SIGKILL", track->pid); track->timer_sigkill = 0; track->last_timeout_signo = SIGKILL; - rc = kill(track->pid, SIGKILL); + rc = kill(-track->pid, SIGKILL); if (rc < 0) { crm_perror(LOG_ERR, "Couldn't send SIGKILL to %d", track->pid); } @@ -835,7 +835,7 @@ internal_stonith_action_execute(stonith_action_t * action) } if (timeout == 0) { - int killrc = kill(pid, SIGKILL); + int killrc = kill(-pid, SIGKILL); if (killrc && errno != ESRCH) { crm_err("kill(%d, KILL) failed: %s (%d)", pid, pcmk_strerror(errno), errno);