45
45
#include <crm/common/util.h>
46
#include <clplumbing/proctrack.h>
49
crmdManagedChildRegistered(ProcTrack * p)
51
struct crm_subsystem_s *the_subsystem = p->privatedata;
53
the_subsystem->pid = p->pid;
57
crmdManagedChildDied(ProcTrack * p, int status, int signo, int exitcode, int waslogged)
59
struct crm_subsystem_s *the_subsystem = p->privatedata;
61
crm_info("Process %s:[%d] exited (signal=%d, exitcode=%d)",
62
the_subsystem->name, the_subsystem->pid, signo, exitcode);
65
/* everything below is now handled in pe_connection_destroy() */
66
the_subsystem->pid = -1;
67
the_subsystem->ipc = NULL;
68
clear_bit_inplace(fsa_input_register, the_subsystem->flag_connected);
70
crm_trace("Triggering FSA: %s", __FUNCTION__);
71
mainloop_set_trigger(fsa_source);
73
if (is_set(fsa_input_register, the_subsystem->flag_required)) {
74
/* this wasnt supposed to happen */
75
crm_warn("The %s subsystem terminated unexpectedly", the_subsystem->name);
77
if (the_subsystem->flag_connected == R_PE_CONNECTED) {
79
char *pid = crm_itoa(the_subsystem->pid);
82
* save the current CIB so that we have a chance of
83
* figuring out what killed it
85
rc = fsa_cib_conn->cmds->query(fsa_cib_conn, NULL, NULL, cib_scope_local);
86
add_cib_op_callback(fsa_cib_conn, rc, TRUE, pid, save_cib_contents);
89
register_fsa_input_before(C_FSA_INTERNAL, I_ERROR, NULL);
48
crmdManagedChildDied(GPid pid, gint status, gpointer user_data)
50
struct crm_subsystem_s *the_subsystem = user_data;
52
if (WIFSIGNALED(status)) {
53
int signo = WTERMSIG(status);
54
int core = WCOREDUMP(status);
56
crm_notice("Child process %s terminated with signal %d (pid=%d, core=%d)",
57
the_subsystem->name, signo, the_subsystem->pid, core);
59
} else if (WIFEXITED(status)) {
60
int exitcode = WEXITSTATUS(status);
62
do_crm_log(exitcode == 0 ? LOG_INFO : LOG_ERR,
63
"Child process %s exited (pid=%d, rc=%d)", the_subsystem->name,
64
the_subsystem->pid, exitcode);
67
crm_err("Process %s:[%d] exited?", the_subsystem->name, the_subsystem->pid);
92
p->privatedata = NULL;
96
crmdManagedChildName(ProcTrack * p)
98
struct crm_subsystem_s *the_subsystem = p->privatedata;
100
return the_subsystem->name;
103
static ProcTrack_ops crmd_managed_child_ops = {
104
crmdManagedChildDied,
105
crmdManagedChildRegistered,
110
72
stop_subsystem(struct crm_subsystem_s *the_subsystem, gboolean force_quit)
216
177
(void)open(devnull, O_WRONLY); /* Stderr: fd 2 */
219
char *opts[] = { crm_strdup(the_subsystem->command), NULL };
180
char *opts[] = { strdup(the_subsystem->command), NULL };
181
/* coverity[toctou] The call to stat() is a fail-fast, not a race */
220
182
(void)execvp(the_subsystem->command, opts);
223
185
/* Should not happen */
224
186
crm_perror(LOG_ERR, "FATAL: Cannot exec %s", the_subsystem->command);
226
exit(100); /* Suppress respawning */
188
crmd_exit(100); /* Suppress respawning */
227
189
return TRUE; /* never reached */