I'm running a Java program as a daemon on Linux using Apache commons-daemon's jsvc.
The daemon "randomly" crashes with only message:
jsvc.exec error: Service did not exit cleanly
This is the relevant part of the code in jsvc
(in jsvc-unix.c
line 1142):
while (waitpid(pid, &status, 0) != pid) {
/* Waith for process */
}
/* The child must have exited cleanly */
if (WIFEXITED(status)) {
status = WEXITSTATUS(status);
// Clean exit code...
}
else {
if (WIFSIGNALED(status)) {
log_error("Service killed by signal %d", WTERMSIG(status));
/* prevent looping */
if (laststart + 60 > time(NULL)) {
log_debug("Waiting 60 s to prevent looping");
sleep(60);
}
continue;
}
log_error("Service did not exit cleanly", status);
return 1;
}
In which case can WIFEXITED
and WIFSIGNALED
both be false ?
Is it guaranteed that the process was not killed in this case (by a process or Linux OOM killer) ?