Browse Source

added sending UID and PID for SIGTERM and SIGINT to the logs

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@1957 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.17
Jan Kneschke 15 years ago
parent
commit
ef19bacae8
  1. 1
      NEWS
  2. 4
      src/log.c
  3. 55
      src/server.c

1
NEWS

@ -5,6 +5,7 @@ NEWS
- 1.4.17 -
* added dir-listing.set-footer in mod_dirlisting (#1277)
* added sending UID and PID for SIGTERM and SIGINT to the logs
* fixed hardcoded font-sizes in mod_dirlisting (#1267)
* fixed different ETag length on 32/64 platforms (#1279)
* fixed compression of files < 128 bytes by disabling compression (#1241)

4
src/log.c

@ -126,14 +126,10 @@ int log_error_cycle(server *srv) {
}
}
log_error_write(srv, __FILE__, __LINE__, "s", "logfiles cycled");
return 0;
}
int log_error_close(server *srv) {
log_error_write(srv, __FILE__, __LINE__, "s", "server stopped");
switch(srv->errorlog_mode) {
case ERRORLOG_FILE:
close(srv->errorlog_fd);

55
src/server.c

@ -70,20 +70,35 @@ static volatile sig_atomic_t handle_sig_alarm = 1;
static volatile sig_atomic_t handle_sig_hup = 0;
#if defined(HAVE_SIGACTION) && defined(SA_SIGINFO)
static volatile siginfo_t last_sigterm_info;
static volatile siginfo_t last_sighup_info;
static void sigaction_handler(int sig, siginfo_t *si, void *context) {
UNUSED(si);
UNUSED(context);
switch (sig) {
case SIGTERM: srv_shutdown = 1; break;
case SIGTERM:
srv_shutdown = 1;
memcpy(&last_sigterm_info, si, sizeof(*si));
break;
case SIGINT:
if (graceful_shutdown) srv_shutdown = 1;
else graceful_shutdown = 1;
break;
case SIGALRM: handle_sig_alarm = 1; break;
case SIGHUP: handle_sig_hup = 1; break;
case SIGCHLD: break;
if (graceful_shutdown) {
srv_shutdown = 1;
} else {
graceful_shutdown = 1;
}
memcpy(&last_sigterm_info, si, sizeof(*si));
break;
case SIGALRM:
handle_sig_alarm = 1;
break;
case SIGHUP:
handle_sig_hup = 1;
memcpy(&last_sighup_info, si, sizeof(*si));
break;
case SIGCHLD:
break;
}
}
#elif defined(HAVE_SIGNAL) || defined(HAVE_SIGACTION)
@ -1079,6 +1094,17 @@ int main (int argc, char **argv) {
log_error_write(srv, __FILE__, __LINE__, "s", "cycling errorlog failed, dying");
return -1;
} else {
#ifdef HAVE_SIGACTION
log_error_write(srv, __FILE__, __LINE__, "sdsd",
"logfiles cycled UID =",
last_sigterm_info.si_uid,
"PID =",
last_sigterm_info.si_pid);
#else
log_error_write(srv, __FILE__, __LINE__, "s",
"logfiles cycled");
#endif
}
}
@ -1378,6 +1404,17 @@ int main (int argc, char **argv) {
}
}
#ifdef HAVE_SIGACTION
log_error_write(srv, __FILE__, __LINE__, "sdsd",
"server stopped by UID =",
last_sigterm_info.si_uid,
"PID =",
last_sigterm_info.si_pid);
#else
log_error_write(srv, __FILE__, __LINE__, "s",
"server stopped");
#endif
/* clean-up */
log_error_close(srv);
network_close(srv);

Loading…
Cancel
Save