do not set stdin, stdout, stderr
Costa Tsaousis (ktsaou) committed
Sep 10, 2018 at 19:47 UTC
4c600529e6538266dd1f81dac4e5b96652916765
1 file changed
+10
-10
src/log.c
+10
-10
@@ -99,16 +99,16 @@ static FILE *open_log_file(int fd, FILE *fp, const char *filename, int *enabled_
99
}
100
}
101
102
- if(devnull && is_stdaccess) {
103
- fd = -1;
104
- fp = NULL;
105
- }
106
-
102
// if there is a level-2 file pointer
103
// flush it before switching the level-1 fds
104
if(fp)
105
fflush(fp);
106
107
+ if(devnull && is_stdaccess) {
108
+ fd = -1;
109
+ fp = NULL;
110
+ }
111
+
112
if(fd != f && fd != -1) {
113
// it automatically closes
114
int t = dup2(f, fd);
@@ -139,10 +139,10 @@ static FILE *open_log_file(int fd, FILE *fp, const char *filename, int *enabled_
139
140
void reopen_all_log_files() {
141
if(stdout_filename)
142
- stdout = open_log_file(STDOUT_FILENO, stdout, stdout_filename, &output_log_syslog, 0, NULL);
142
+ open_log_file(STDOUT_FILENO, stdout, stdout_filename, &output_log_syslog, 0, NULL);
143
144
if(stderr_filename)
145
- stderr = open_log_file(STDERR_FILENO, stderr, stderr_filename, &error_log_syslog, 0, NULL);
145
+ open_log_file(STDERR_FILENO, stderr, stderr_filename, &error_log_syslog, 0, NULL);
146
147
if(stdaccess_filename)
148
stdaccess = open_log_file(stdaccess_fd, stdaccess, stdaccess_filename, &access_log_syslog, 1, &stdaccess_fd);
@@ -150,10 +150,10 @@ void reopen_all_log_files() {
150
151
void open_all_log_files() {
152
// disable stdin
153
- stdin = open_log_file(STDIN_FILENO, stdin, "/dev/null", NULL, 0, NULL);
153
+ open_log_file(STDIN_FILENO, stdin, "/dev/null", NULL, 0, NULL);
154
155
- stdout = open_log_file(STDOUT_FILENO, stdout, stdout_filename, &output_log_syslog, 0, NULL);
156
- stderr = open_log_file(STDERR_FILENO, stderr, stderr_filename, &error_log_syslog, 0, NULL);
155
+ open_log_file(STDOUT_FILENO, stdout, stdout_filename, &output_log_syslog, 0, NULL);
156
+ open_log_file(STDERR_FILENO, stderr, stderr_filename, &error_log_syslog, 0, NULL);
157
stdaccess = open_log_file(stdaccess_fd, stdaccess, stdaccess_filename, &access_log_syslog, 1, &stdaccess_fd);
158
}
159