> > > > elogd continues to run after a SIGHUP. If a second SIGHUP is received the daemon terminates.
> > > > This was observed on Solaris 10 (SPARC).
> > > > The documentation states that elogd should re-read configuration after receiving SIGHUP.
> > >
> > > I tried to reproduce this but without success. I could send many SIGHUPs without the daemon terminating. Maybe
> > > you modified the configuration file in between and elogd barked out because of some wrong configuration? Try to
> > > start the daemon interactively and see what exactly happens if you send several SIGHUPs.
> >
> > The problem is that under Solaris signal handlers installed via signal() get uninstalled *before* the signal handler
> > is called. Thus the second time elogd receives a SIGHUP, you get the default action, which is to kill the process.
> >
> > The solution is to use the POSIX sigaction() call instead of signal().
>
> Can you try to modify the signal() calls into sigaction(). If this really works under Solaris, I will incorporate this
> then into the distribution.
Here is the patch. It works under both Solaris and Linux. |
*** src/elogd.c-orig 2009-04-14 04:16:02.000000000 -0400
--- src/elogd.c 2009-06-04 11:33:31.337804000 -0400
***************
*** 27553,27558 ****
--- 27553,27565 ----
SSL_CTX *ssl_ctx;
#endif
+ /*
+ * sigaction structs
+ */
+ struct sigaction ctrlc_handle;
+ struct sigaction ignore_handle;
+ struct sigaction hup_handle;
+
i_conn = content_length = 0;
net_buffer_size = 100000;
net_buffer = xmalloc(net_buffer_size);
***************
*** 27708,27718 ****
close(fd);
}
! /* install signal handler */
! signal(SIGTERM, ctrlc_handler);
! signal(SIGINT, ctrlc_handler);
! signal(SIGPIPE, SIG_IGN);
! signal(SIGHUP, hup_handler);
/* give up root privilege */
if (geteuid() == 0) {
if (!getcfg("global", "Grp", str, sizeof(str)) || setegroup(str) < 0) {
--- 27715,27739 ----
close(fd);
}
! /*
! * install signal handlers
! */
! ctrlc_handle.sa_handler = ctrlc_handler;
! sigemptyset( &ctrlc_handle.sa_mask );
! ctrlc_handle.sa_flags = 0;
!
! sigaction(SIGTERM, &ctrlc_handle, NULL);
! sigaction(SIGINT, &ctrlc_handle, NULL);
!
! ignore_handle.sa_handler = SIG_IGN;
! sigaction(SIGPIPE, &ignore_handle, NULL);
!
! hup_handle.sa_handler = hup_handler;
! sigemptyset( &hup_handle.sa_mask );
! hup_handle.sa_flags = 0;
! sigaction(SIGHUP, &hup_handle, NULL);
!
!
/* give up root privilege */
if (geteuid() == 0) {
if (!getcfg("global", "Grp", str, sizeof(str)) || setegroup(str) < 0) {
|