#define YAZ_DAEMON_FORK 1
#define YAZ_DAEMON_DEBUG 2
#define YAZ_DAEMON_KEEPALIVE 4
+#define YAZ_DAEMON_LOG_REOPEN 8
/** \brief daemon utility.
\param progname program name for logging purposes.
Flag YAZ_DAEMON_KEEPALIVE: Repeatedly calls work handler if it makes a
"fatal" error.
+
+ Flag YAZ_DAEMON_KEEPALIVE: Re-opens yaz log if SIGHUP is received
*/
YAZ_EXPORT
int yaz_daemon(const char *progname,
}
}
+static void log_reopen_handler(int num)
+{
+ yaz_log_reopen();
+ if (child_pid)
+ kill(child_pid, num);
+}
+
static void sigusr2_handler(int num)
{
child_got_signal_from_us = 1;
int no_sigbus = 0;
int run = 1;
int cont = 1;
- void (*old_sighup)(int);
void (*old_sigterm)(int);
void (*old_sigusr1)(int);
struct sigaction sa2, sa1;
/* keep signals in their original state and make sure that some signals
to parent process also gets sent to the child.. */
- old_sighup = signal(SIGHUP, normal_stop_handler);
old_sigterm = signal(SIGTERM, normal_stop_handler);
old_sigusr1 = signal(SIGUSR1, normal_stop_handler);
else if (p == 0)
{
/* child */
- signal(SIGHUP, old_sighup); /* restore */
signal(SIGTERM, old_sigterm);/* restore */
signal(SIGUSR1, old_sigusr1);/* restore */
sigaction(SIGUSR2, &sa1, NULL);
write_pidfile(pid_fd);
+ if (flags & YAZ_DAEMON_LOG_REOPEN)
+ {
+ signal(SIGHUP, log_reopen_handler);
+ }
if (flags & YAZ_DAEMON_KEEPALIVE)
{
keepalive(work, data);