aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sysklogd/syslogd.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 38ea3d7ff..f624eb7f6 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -301,17 +301,23 @@ static void log_locally(time_t now, char *msg)
301 } 301 }
302#endif 302#endif
303 if (G.logFD >= 0) { 303 if (G.logFD >= 0) {
304 /* Reopen log file every second. This allows admin
305 * to delete the file and not worry about restarting us.
306 * This costs almost nothing since it happens
307 * _at most_ once a second.
308 */
304 if (!now) 309 if (!now)
305 now = time(NULL); 310 now = time(NULL);
306 if (G.last_log_time != now) { 311 if (G.last_log_time != now) {
307 G.last_log_time = now; /* reopen log file every second */ 312 G.last_log_time = now;
308 close(G.logFD); 313 close(G.logFD);
309 goto reopen; 314 goto reopen;
310 } 315 }
311 } else { 316 } else {
312 reopen: 317 reopen:
313 G.logFD = device_open(G.logFilePath, O_WRONLY | O_CREAT 318 G.logFD = open(G.logFilePath, O_WRONLY | O_CREAT
314 | O_NOCTTY | O_APPEND | O_NONBLOCK); 319 | O_NOCTTY | O_APPEND | O_NONBLOCK,
320 0666);
315 if (G.logFD < 0) { 321 if (G.logFD < 0) {
316 /* cannot open logfile? - print to /dev/console then */ 322 /* cannot open logfile? - print to /dev/console then */
317 int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK); 323 int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);