Browse Source

Handle process exiting in the watchdog by shutting down

master
Con Kolivas 11 years ago
parent
commit
da435ac22b
  1. 10
      src/ckpool.c

10
src/ckpool.c

@ -388,16 +388,20 @@ static void *watchdog(void *arg)
while (42) { while (42) {
proc_instance_t *pi; proc_instance_t *pi;
time_t relaunch_t; time_t relaunch_t;
int pid; int pid, status;
pid = waitpid(0, NULL, 0); pid = waitpid(0, &status, 0);
pi = child_by_pid(ckp, pid);
if (pi && WIFEXITED(status)) {
LOGWARNING("Child process %s exited, terminating!", pi->processname);
break;
}
relaunch_t = time(NULL); relaunch_t = time(NULL);
if (relaunch_t == last_relaunch_t) { if (relaunch_t == last_relaunch_t) {
LOGEMERG("Respawning processes too fast, exiting!"); LOGEMERG("Respawning processes too fast, exiting!");
break; break;
} }
last_relaunch_t = relaunch_t; last_relaunch_t = relaunch_t;
pi = child_by_pid(ckp, pid);
if (pi) { if (pi) {
LOGERR("%s process dead! Relaunching", pi->processname); LOGERR("%s process dead! Relaunching", pi->processname);
launch_process(pi); launch_process(pi);

Loading…
Cancel
Save