diff --git a/lib/util/debug.c b/lib/util/debug.c index 141f3a595ca..d41e0f99c77 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -1077,8 +1077,11 @@ bool reopen_logs_internal(void) force_check_log_size(); (void)umask(oldumask); - /* Take over stderr to catch output into logs */ - if (state.fd > 0) { + /* + * If log file was opened or created successfully, take over stderr to + * catch output into logs. + */ + if (new_fd != -1) { if (dup2(state.fd, 2) == -1) { /* Close stderr too, if dup2 can't point it - at the logfile. There really isn't much