summaryrefslogtreecommitdiff
path: root/lib/libfrr.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libfrr.c')
-rw-r--r--lib/libfrr.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 0a575abac6..a1982841d3 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -1125,9 +1125,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);
}
}
@@ -1213,9 +1216,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);
}