summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-07-23 18:54:57 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-07-23 19:02:31 -0400
commit42ab331dc903f3cd0399d76807ff9fa25b5efcba (patch)
tree4b391ba066c753ca614edc214d3b9c33d3a6fad0
parent7bda136e5ffc6a551590a9b7cc8a1c12c19f612e (diff)
downloadlighttpd1.4-42ab331dc903f3cd0399d76807ff9fa25b5efcba.tar.gz
lighttpd1.4-42ab331dc903f3cd0399d76807ff9fa25b5efcba.zip
[core] consistent behavior w/ and w/o SA_SIGINFO
and consistent open of server.pid-file
-rw-r--r--src/server.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/server.c b/src/server.c
index bad0b49d..ec203c41 100644
--- a/src/server.c
+++ b/src/server.c
@@ -154,6 +154,12 @@ static void sigaction_handler(int sig, siginfo_t *si, void *context) {
static void signal_handler(int sig) {
switch (sig) {
case SIGTERM: srv_shutdown = 1; break;
+ case SIGUSR1:
+ if (!graceful_shutdown) {
+ graceful_restart = 1;
+ graceful_shutdown = 1;
+ }
+ break;
case SIGINT:
if (graceful_shutdown) {
if (2 == graceful_restart)
@@ -165,7 +171,20 @@ static void signal_handler(int sig) {
}
break;
case SIGALRM: handle_sig_alarm = 1; break;
- case SIGHUP: handle_sig_hup = 1; break;
+ case SIGHUP:
+ /**
+ * we send the SIGHUP to all procs in the process-group
+ * this includes ourself
+ *
+ * make sure we only send it once and don't create a
+ * infinite loop
+ */
+ if (!forwarded_sig_hup) {
+ handle_sig_hup = 1;
+ } else {
+ forwarded_sig_hup = 0;
+ }
+ break;
case SIGCHLD: break;
}
}
@@ -1239,7 +1258,7 @@ static int server_main (server * const srv, int argc, char **argv) {
return -1;
}
- if (-1 == (pid_fd = open(srv->srvconf.pid_file->ptr, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) {
+ if (-1 == (pid_fd = fdevent_open_cloexec(srv->srvconf.pid_file->ptr, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) {
log_error_write(srv, __FILE__, __LINE__, "sbs",
"opening pid-file failed:", srv->srvconf.pid_file, strerror(errno));
return -1;