+}
+
+int main(int argc, char **argv)
+{
+ int cont = 1;
+ static int mk_pid = 0;
+ Yaz_SocketManager mySocketManager;
+ Yaz_Proxy proxy(new Yaz_PDU_Assoc(&mySocketManager));
+
+ static_yaz_proxy = &proxy;
+
+ signal(SIGHUP, sighup_handler);
+
+ args(&proxy, argc, argv);
+
+ if (debug)
+ {
+ child_run(&mySocketManager);
+ exit(0);
+ }
+ while (cont)
+ {
+ pid_t p = fork();
+ if (p == (pid_t) -1)
+ {
+ yaz_log(LOG_FATAL|LOG_ERRNO, "fork");
+ exit(1);
+ }
+ else if (p == 0)
+ {
+ child_run(&mySocketManager);
+ }
+ pid_t p1;
+ int status;
+ p1 = wait(&status);
+ if (p1 != p)
+ {
+ yaz_log(LOG_FATAL, "p1=%d != p=%d", p1, p);
+ exit(1);
+ }
+ if (WIFSIGNALED(status))
+ {
+ switch(WTERMSIG(status)) {
+ case SIGILL:
+ yaz_log(LOG_WARN, "Received SIGILL from child %ld", (long) p);
+ cont = 1;
+ break;
+ case SIGABRT:
+ yaz_log(LOG_WARN, "Received SIGABRT from child %ld", (long) p);
+ cont = 1;
+ break ;
+ case SIGSEGV:
+ yaz_log(LOG_WARN, "Received SIGSEGV from child %ld", (long) p);
+ cont = 1;
+ break;
+ case SIGTERM:
+ yaz_log(LOG_LOG, "Received SIGTERM from child %ld",
+ WTERMSIG(status), (long) p);
+ cont = 0;
+ break;
+ default:
+ yaz_log(LOG_WARN, "Received SIG %d from child %ld",
+ WTERMSIG(status), (long) p);
+ cont = 0;
+ }
+ }
+ else if (status == 0)
+ cont = 0;
+ else
+ {
+ yaz_log(LOG_LOG, "Exit %d from child %ld", status, (long) p);
+ cont = 1;
+ }
+ if (cont)
+ sleep(1);
+ }
+ exit (0);