From a57eba2bb49b32f3dc69542de69b8b74ec9d3d09 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 3 May 2012 11:42:41 +1000 Subject: Track all child process so we never send a signal to an unrelated process (our child died and kernel wrapped the pid-space and reused the pid for a different process Wrap all creation of child processes inside ctdb_fork() which is used to track all processes we have spawned. Capture SIGCHLD to track also which child processes have terminated. Wrap kill() inside ctdb_kill() and make sure that we never send a !0 signal to a child process pid that has already terminated (and might have been replaced with a (This used to be ctdb commit f73a4b1495830bcdd094a93732a89dd53b3c2f78) --- ctdb/server/eventscript.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ctdb/server/eventscript.c') diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 50ff7c3ceba..838b12e16e6 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -473,7 +473,7 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event /* valgrind gets overloaded if we run next script as it's still doing * post-execution analysis, so kill finished child here. */ if (ctdb->valgrinding) { - kill(state->child, SIGKILL); + ctdb_kill(ctdb, state->child, SIGKILL); } state->child = 0; @@ -529,7 +529,7 @@ static void debug_timeout(struct ctdb_event_script_state *state) if (pid == 0) { system(buf); /* Now we can kill the child */ - kill(state->child, SIGTERM); + ctdb_kill(state->ctdb, state->child, SIGTERM); exit(0); } if (pid == -1) { @@ -584,7 +584,7 @@ static int event_script_destructor(struct ctdb_event_script_state *state) if (state->child) { DEBUG(DEBUG_ERR,(__location__ " Sending SIGTERM to child pid:%d\n", state->child)); - if (kill(state->child, SIGTERM) != 0) { + if (ctdb_kill(state->ctdb, state->child, SIGTERM) != 0) { DEBUG(DEBUG_ERR,("Failed to kill child process for eventscript, errno %s(%d)\n", strerror(errno), errno)); } } -- cgit