|
|
| version 1.1, 2013/10/14 10:32:47 | version 1.1.1.2, 2014/06/15 20:20:06 |
|---|---|
| Line 122 int open_logfile_or_pipe(server *srv, const char* logf | Line 122 int open_logfile_or_pipe(server *srv, const char* logf |
| return -1; | return -1; |
| } | } |
| #ifdef FD_CLOEXEC | fd_close_on_exec(fd); |
| fcntl(fd, F_SETFD, FD_CLOEXEC); | |
| #endif | |
| return fd; | return fd; |
| } | } |
| Line 178 int log_error_open(server *srv) { | Line 176 int log_error_open(server *srv) { |
| if (srv->errorlog_mode == ERRORLOG_FD) { | if (srv->errorlog_mode == ERRORLOG_FD) { |
| srv->errorlog_fd = dup(STDERR_FILENO); | srv->errorlog_fd = dup(STDERR_FILENO); |
| #ifdef FD_CLOEXEC | fd_close_on_exec(srv->errorlog_fd); |
| fcntl(srv->errorlog_fd, F_SETFD, FD_CLOEXEC); | |
| #endif | |
| } | } |
| if (-1 == (breakage_fd = open_logfile_or_pipe(srv, logfile))) { | if (-1 == (breakage_fd = open_logfile_or_pipe(srv, logfile))) { |
| Line 231 int log_error_cycle(server *srv) { | Line 227 int log_error_cycle(server *srv) { |
| /* ok, new log is open, close the old one */ | /* ok, new log is open, close the old one */ |
| close(srv->errorlog_fd); | close(srv->errorlog_fd); |
| srv->errorlog_fd = new_fd; | srv->errorlog_fd = new_fd; |
| #ifdef FD_CLOEXEC | fd_close_on_exec(srv->errorlog_fd); |
| /* close fd on exec (cgi) */ | |
| fcntl(srv->errorlog_fd, F_SETFD, FD_CLOEXEC); | |
| #endif | |
| } | } |
| } | } |
| Line 369 static void log_write(server *srv, buffer *b) { | Line 362 static void log_write(server *srv, buffer *b) { |
| case ERRORLOG_FILE: | case ERRORLOG_FILE: |
| case ERRORLOG_FD: | case ERRORLOG_FD: |
| buffer_append_string_len(b, CONST_STR_LEN("\n")); | buffer_append_string_len(b, CONST_STR_LEN("\n")); |
| force_assert(b->used > 0); | |
| write(srv->errorlog_fd, b->ptr, b->used - 1); | write(srv->errorlog_fd, b->ptr, b->used - 1); |
| break; | break; |
| case ERRORLOG_SYSLOG: | case ERRORLOG_SYSLOG: |