Skip to content

Commit

Permalink
Merge pull request #16966 from FRRouting/mergify/bp/stable/9.1/pr-16738
Browse files Browse the repository at this point in the history
lib: Attach stdout to child only if --log=stdout and stdout FD is a tty (backport #16738)
  • Loading branch information
donaldsharp authored Oct 1, 2024
2 parents cd82888 + b496e4b commit 934b41e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/libfrr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,9 +1108,12 @@ static void frr_terminal_close(int isexit)
* don't redirect when stdout is set with --log stdout
*/
for (fd = 2; fd >= 0; fd--)
if (isatty(fd) &&
(fd != STDOUT_FILENO || !logging_to_stdout))
if (logging_to_stdout && isatty(fd) &&
fd == STDOUT_FILENO) {
/* Do nothing. */
} else {
dup2(nullfd, fd);
}
close(nullfd);
}
}
Expand Down Expand Up @@ -1196,9 +1199,12 @@ void frr_run(struct event_loop *master)
* stdout
*/
for (fd = 2; fd >= 0; fd--)
if (isatty(fd) &&
(fd != STDOUT_FILENO || !logging_to_stdout))
if (logging_to_stdout && isatty(fd) &&
fd == STDOUT_FILENO) {
/* Do nothing. */
} else {
dup2(nullfd, fd);
}
close(nullfd);
}

Expand Down

0 comments on commit 934b41e

Please sign in to comment.