|
|
@ -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); |
|
|
|