diff options
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: log.c,v 1.51 2018/07/27 12:03:17 markus Exp $ */ | 1 | /* $OpenBSD: log.c,v 1.52 2020/07/03 06:46:41 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -370,6 +370,14 @@ log_redirect_stderr_to(const char *logfile) | |||
370 | { | 370 | { |
371 | int fd; | 371 | int fd; |
372 | 372 | ||
373 | if (logfile == NULL) { | ||
374 | if (log_stderr_fd != STDERR_FILENO) { | ||
375 | close(log_stderr_fd); | ||
376 | log_stderr_fd = STDERR_FILENO; | ||
377 | } | ||
378 | return; | ||
379 | } | ||
380 | |||
373 | if ((fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0600)) == -1) { | 381 | if ((fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0600)) == -1) { |
374 | fprintf(stderr, "Couldn't open logfile %s: %s\n", logfile, | 382 | fprintf(stderr, "Couldn't open logfile %s: %s\n", logfile, |
375 | strerror(errno)); | 383 | strerror(errno)); |