X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=appimage%2Fctdlvisor.c;h=6784f2cc5d042998ca55eb2f8068dcbca87be656;hp=7e2c25b29765e351d0e7831596b8919653f0c455;hb=fe70bc8314205d9c32da7c73e5bf1c58ee1a67f6;hpb=76a0216278f0a014d3533de9150adbc9f74085ab diff --git a/appimage/ctdlvisor.c b/appimage/ctdlvisor.c index 7e2c25b29..6784f2cc5 100644 --- a/appimage/ctdlvisor.c +++ b/appimage/ctdlvisor.c @@ -71,15 +71,7 @@ void signal_handler(int signal) { what_exited = "unknown"; } if (who_exited >= 0) { - if (WIFEXITED(status)) { - fprintf(stderr, "ctdlvisor: %d (%s) exited, exitcode=%d\n", who_exited, what_exited, WEXITSTATUS(status)); - } - else if (WIFSIGNALED(status)) { - fprintf(stderr, "ctdlvisor: %d (%s) crashed, signal=%d\n", who_exited, what_exited, WTERMSIG(status)); - } - else { - fprintf(stderr, "ctdlvisor: %d (%s) ended, status=%d\n", who_exited, what_exited, status); - } + fprintf(stderr, "ctdlvisor: %d (%s) ended, status=%d\n", who_exited, what_exited, status); } } while (who_exited >= 0); ctdlvisor_exit(0); @@ -170,19 +162,22 @@ void main_loop(void) { // If it crashes, however, we will start it back up. if (who_exited == citserver_pid) { citserver_exit_code = WEXITSTATUS(status); - if (citserver_exit_code == 0) { + if ((WIFEXITED(status)) && (citserver_exit_code == 0)) { fprintf(stderr, "ctdlvisor: citserver exited normally - ending AppImage session\n"); shutting_down = 1; kill(webcit_pid, SIGTERM); kill(webcits_pid, SIGTERM); } - else if ((citserver_exit_code >= 101) && (citserver_exit_code <= 109)) { + else if ((WIFEXITED(status)) && (citserver_exit_code >= 101) && (citserver_exit_code <= 109)) { fprintf(stderr, "ctdlvisor: citserver exited intentionally - ending AppImage session\n"); shutting_down = 1; kill(webcit_pid, SIGTERM); kill(webcits_pid, SIGTERM); } else { + if (WIFSIGNALED(status)) { + fprintf(stderr, "ctdlvisor: citserver crashed on signal %d\n", WTERMSIG(status)); + } citserver_pid = start_citadel(); } }