return 1;
}
-int iochan_event_loop(IOCHAN *iochans)
+int iochan_event_loop(IOCHAN *iochans, int *watch_sig)
{
do /* loop as long as there are active associations to process */
{
if (yaz_errno() == EINTR)
{
xfree(fds);
+ if (watch_sig && *watch_sig)
+ break;
continue;
}
else
IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags, int port);
int iochan_is_alive(IOCHAN chan);
-int iochan_event_loop(IOCHAN *iochans);
+int iochan_event_loop(IOCHAN *iochans, int *watch_sig);
void statserv_remove (IOCHAN pIOChannel);
#endif
/*
void __cdecl event_loop_thread(IOCHAN iochan)
{
- iochan_event_loop(&iochan);
+ iochan_event_loop(&iochan, 0);
}
/* WIN32 listener */
control_block.one_shot = 1;
if (control_block.threads)
{
- iochan_event_loop(&new_chan);
+ iochan_event_loop(&new_chan, 0);
}
else
{
{
}
-static void daemon_handler(void *data)
-{
- IOCHAN *pListener = data;
- iochan_event_loop(pListener);
-}
+static int sig_received = 0;
#ifndef WIN32
static void normal_stop_handler(int num)
{
- yaz_log(log_server, "Received SIGTERM. PID=%ld", (long) getpid());
- exit(0);
+ sig_received = num;
}
#endif
+static void daemon_handler(void *data)
+{
+ IOCHAN *pListener = data;
+ iochan_event_loop(pListener, &sig_received);
+}
+
static void show_version(void)
{
char vstr[20], sha1_str[41];
daemon_handler, &pListener,
*control_block.pid_fname ? control_block.pid_fname : 0,
*control_block.setuid ? control_block.setuid : 0);
+#ifndef WIN32
+ if (sig_received)
+ yaz_log(YLOG_LOG, "Received SIGTERM PID=%ld", (long) getpid());
+#endif
return 0;
}