+pid_t citserver_pid;
+pid_t webcit_pid;
+pid_t webcits_pid;
+
+
+void signal_handler(int signal) {
+ fprintf(stderr, "ctdlvisor: caught signal %d", signal);
+
+ int status;
+ pid_t who_exited;
+ char *what_exited = NULL;
+
+ do {
+ fprintf(stderr, "ctdlvisor: waiting for any child process to exit...\n");
+ who_exited = waitpid(-1, &status, 0);
+ if (who_exited == citserver_pid) {
+ what_exited = "Citadel Server";
+ }
+ else if (who_exited == webcit_pid) {
+ what_exited = "WebCit HTTP";
+ }
+ else if (who_exited == webcits_pid) {
+ what_exited = "WebCit HTTPS";
+ }
+ else {
+ what_exited = "unknown";
+ }
+ fprintf(stderr, "ctdlvisor: pid=%d (%s) exited, status=%d, exitcode=%d\n", who_exited, what_exited, status, WEXITSTATUS(status));
+ } while (who_exited >= 0);
+
+ printf("ctdlvisor: exiting from signal catcher.\n");
+ exit(0);
+}
+
+