{
struct ctdb_context *ctdb = talloc_get_type(p, struct ctdb_context);
+ /* make sure we harvest the child if signals are blocked for some
+ reason
+ */
+ waitpid(ctdb->recoverd_pid, 0, WNOHANG);
+
if (kill(ctdb->recoverd_pid, 0) != 0) {
DEBUG(DEBUG_ERR,("Recovery daemon (pid:%d) is no longer running. Shutting down main daemon\n", (int)ctdb->recoverd_pid));
{
struct ctdb_event_script_state *state =
talloc_get_type(p, struct ctdb_event_script_state);
+ int status = -1;
void (*callback)(struct ctdb_context *, int, void *) = state->callback;
void *private_data = state->private_data;
struct ctdb_context *ctdb = state->ctdb;
- signed char rt = -1;
- int ret;
- ret = read(state->fd[0], &rt, sizeof(rt));
- if (ret != sizeof(rt)) {
- DEBUG(DEBUG_ERR, (__location__ " Failed to read from pipe to eventscript child.\n"));
+ waitpid(state->child, &status, 0);
+ if (status != -1) {
+ status = WEXITSTATUS(status);
}
-
talloc_set_destructor(state, NULL);
talloc_free(state);
- callback(ctdb, rt, private_data);
+ callback(ctdb, status, private_data);
ctdb->event_script_timeouts = 0;
}
{
DEBUG(DEBUG_ERR,(__location__ " Sending SIGTERM to child pid:%d\n", state->child));
kill(state->child, SIGTERM);
+ waitpid(state->child, NULL, 0);
return 0;
}
}
if (state->child == 0) {
- signed char rt;
-
close(state->fd[0]);
if (ctdb->do_setsched) {
ctdb_restore_scheduler(ctdb);
}
set_close_on_exec(state->fd[1]);
- rt = ctdb_event_script_v(ctdb, state->options);
- do {
- ret = write(state->fd[1], &rt, sizeof(rt));
- if (ret != sizeof(rt)) {
- DEBUG(DEBUG_ERR, (__location__ " Failed to write to pipe from eventscript child. Trying again in one second\n"));
- sleep(1);
- }
- } while (ret != sizeof(rt));
- _exit(rt);
+ ret = ctdb_event_script_v(ctdb, state->options);
+ _exit(ret);
}
talloc_set_destructor(state, event_script_destructor);