-#ifdef WIN32
- child_run(&mySocketManager, run);
-#else
- if (debug)
- {
- child_run(&mySocketManager, run);
- exit(0);
- }
- while (cont)
- {
- pid_t p = fork();
- if (p == (pid_t) -1)
- {
- yaz_log(YLOG_FATAL|YLOG_ERRNO, "fork");
- exit(1);
- }
- else if (p == 0)
- {
- child_run(&mySocketManager, run);
- }
- pid_t p1;
- int status;
- p1 = wait(&status);
-
- yaz_log_reopen();
-
- if (p1 != p)
- {
- yaz_log(YLOG_FATAL, "p1=%d != p=%d", p1, p);
- exit(1);
- }
- if (WIFSIGNALED(status))
- {
- switch(WTERMSIG(status)) {
- case SIGILL:
- yaz_log(YLOG_WARN, "Received SIGILL from child %ld", (long) p);
- cont = 1;
- break;
- case SIGABRT:
- yaz_log(YLOG_WARN, "Received SIGABRT from child %ld", (long) p);
- cont = 1;
- break ;
- case SIGSEGV:
- yaz_log(YLOG_WARN, "Received SIGSEGV from child %ld", (long) p);
- cont = 1;
- break;
- case SIGBUS:
- yaz_log(YLOG_WARN, "Received SIGBUS from child %ld", (long) p);
- cont = 1;
- break;
- case SIGTERM:
- yaz_log(YLOG_LOG, "Received SIGTERM from child %ld",
- (long) p);
- cont = 0;
- break;
- default:
- yaz_log(YLOG_WARN, "Received SIG %d from child %ld",
- WTERMSIG(status), (long) p);
- cont = 0;
- }
- }
- else if (status == 0)
- cont = 0;
- else
- {
- yaz_log(YLOG_LOG, "Exit %d from child %ld", status, (long) p);
- cont = 1;
- }
- if (cont)
- sleep(1 + run/5);
- run++;
- }
-#endif
+ yaz_daemon("yazproxy", daemon_flags,
+ child_run, &mySocketManager, pid_fname, uid);