*/
static void sigterm(int sig)
{
+ pid_t pid;
+
/* all the child processes will be running in the same process group */
- kill(-getpgrp(), SIGKILL);
+ pid = getpgrp();
+ if (pid == -1) {
+ kill(-getpid(), SIGKILL);
+ } else {
+ kill(-pid, SIGKILL);
+ }
_exit(1);
}
tree_item = talloc(tree, struct ctdb_script_tree_item);
if (tree_item == NULL) {
DEBUG(DEBUG_ERR, (__location__ " Failed to allocate new tree item\n"));
+ closedir(dir);
talloc_free(tmp_ctx);
return NULL;
}
tree_item->name = talloc_strdup(tree_item, de->d_name);
if (tree_item->name == NULL) {
DEBUG(DEBUG_ERR,(__location__ " Failed to allocate script name.\n"));
+ closedir(dir);
talloc_free(tmp_ctx);
return NULL;
}
ctdb_eventscript_call_names[state->call]);
close(state->fd[0]);
set_close_on_exec(state->fd[1]);
+ ctdb_set_process_name("ctdb_eventscript");
rt = child_run_script(ctdb, state->from_user, state->call, state->options, current);
/* We must be able to write PIPEBUF bytes at least; if this
if (pid == 0) {
char *buf;
+ ctdb_set_process_name("ctdb_debug_hung_script");
if (getenv("CTDB_DEBUG_HUNG_SCRIPT") != NULL) {
debug_hung_script = getenv("CTDB_DEBUG_HUNG_SCRIPT");
}
case CTDB_EVENT_RECOVERED:
case CTDB_EVENT_TAKE_IP:
case CTDB_EVENT_RELEASE_IP:
- case CTDB_EVENT_STOPPED:
case CTDB_EVENT_STATUS:
state->scripts->scripts[state->current].status = 0;
DEBUG(DEBUG_ERR,("Ignoring hung script for %s call %d\n", state->options, state->call));
case CTDB_EVENT_STARTUP:
case CTDB_EVENT_START_RECOVERY:
case CTDB_EVENT_RECOVERED:
- case CTDB_EVENT_STOPPED:
case CTDB_EVENT_MONITOR:
case CTDB_EVENT_STATUS:
case CTDB_EVENT_SHUTDOWN:
CTDB_EVENT_SHUTDOWN,
CTDB_EVENT_RELEASE_IP,
CTDB_EVENT_IPREALLOCATED,
- CTDB_EVENT_STOPPED
};
int i;
for (i=0;i<ARRAY_SIZE(allowed_calls);i++) {
va_start(ap, fmt);
ret = ctdb_event_script_callback_v(ctdb, ctdb,
event_script_callback, &status, false, call, fmt, ap);
+ va_end(ap);
if (ret != 0) {
return ret;
}
- va_end(ap);
status.status = -1;
status.done = false;
" Immediately banning ourself for %d seconds\n",
ctdb_eventscript_call_names[call],
ctdb->tunable.recovery_ban_period));
- ctdb_ban_self(ctdb);
+
+ /* Don't ban self if CTDB is starting up or shutting down */
+ if (call != CTDB_EVENT_INIT && call != CTDB_EVENT_SHUTDOWN) {
+ ctdb_ban_self(ctdb);
+ }
}
return status.status;