summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-07-25 01:49:18 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-07-25 01:49:18 -0400
commitfad841d69bc068b89074b1e6a8bbd2baac85116a (patch)
tree16d0eed1801b5d23943d24c9aab82dc538e88104
parent42ab331dc903f3cd0399d76807ff9fa25b5efcba (diff)
downloadlighttpd1.4-fad841d69bc068b89074b1e6a8bbd2baac85116a.tar.gz
lighttpd1.4-fad841d69bc068b89074b1e6a8bbd2baac85116a.zip
[core] do not remove pid-file in test mode
do not remove pid-file in test mode (whether test passes or fails) (thx m4t)
-rw-r--r--src/server.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/server.c b/src/server.c
index ec203c41..a14e7f6d 100644
--- a/src/server.c
+++ b/src/server.c
@@ -85,7 +85,7 @@
#endif
static int oneshot_fd = 0;
-static volatile int pid_fd = -1;
+static volatile int pid_fd = -2;
static server_socket_array graceful_sockets;
static volatile sig_atomic_t graceful_restart = 0;
static volatile sig_atomic_t graceful_shutdown = 0;
@@ -417,7 +417,7 @@ static void server_free(server *srv) {
}
static void remove_pid_file(server *srv) {
- if (pid_fd < -2) return;
+ if (pid_fd <= -2) return;
if (!buffer_string_is_empty(srv->srvconf.pid_file) && 0 <= pid_fd) {
if (0 != ftruncate(pid_fd, 0)) {
log_error_write(srv, __FILE__, __LINE__, "sbds",
@@ -1153,13 +1153,13 @@ static int server_main (server * const srv, int argc, char **argv) {
}
if (test_config) {
+ buffer_reset(srv->srvconf.pid_file);
if (1 == test_config) {
printf("Syntax OK\n");
} else { /*(test_config > 1)*/
test_config = 0;
srv->srvconf.preflight_check = 1;
srv->srvconf.dont_daemonize = 1;
- buffer_reset(srv->srvconf.pid_file);
}
}
@@ -1238,6 +1238,7 @@ static int server_main (server * const srv, int argc, char **argv) {
}
/* open pid file BEFORE chroot */
+ if (-2 == pid_fd) pid_fd = -1; /*(initial startup state)*/
if (-1 == pid_fd && !buffer_string_is_empty(srv->srvconf.pid_file)) {
if (-1 == (pid_fd = fdevent_open_cloexec(srv->srvconf.pid_file->ptr, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) {
struct stat st;