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