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 48b875ef1..89391036a 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -306,17 +306,23 @@ static void log_locally(time_t now, char *msg)
306 } 306 }
307#endif 307#endif
308 if (G.logFD >= 0) { 308 if (G.logFD >= 0) {
309 /* Reopen log file every second. This allows admin
310 * to delete the file and not worry about restarting us.
311 * This costs almost nothing since it happens
312 * _at most_ once a second.
313 */
309 if (!now) 314 if (!now)
310 now = time(NULL); 315 now = time(NULL);
311 if (G.last_log_time != now) { 316 if (G.last_log_time != now) {
312 G.last_log_time = now; /* reopen log file every second */ 317 G.last_log_time = now;
313 close(G.logFD); 318 close(G.logFD);
314 goto reopen; 319 goto reopen;
315 } 320 }
316 } else { 321 } else {
317 reopen: 322 reopen:
318 G.logFD = device_open(G.logFilePath, O_WRONLY | O_CREAT 323 G.logFD = open(G.logFilePath, O_WRONLY | O_CREAT
319 | O_NOCTTY | O_APPEND | O_NONBLOCK); 324 | O_NOCTTY | O_APPEND | O_NONBLOCK,
325 0666);
320 if (G.logFD < 0) { 326 if (G.logFD < 0) {
321 /* cannot open logfile? - print to /dev/console then */ 327 /* cannot open logfile? - print to /dev/console then */
322 int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK); 328 int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);