From: Donald Sharp Date: Tue, 22 Oct 2024 15:13:07 +0000 (-0400) Subject: Revert "lib: Attach stdout to child only if --log=stdout and stdout FD is a tty" X-Git-Tag: docker/9.1.3~21^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=9d5dc5dd8d58e5f7c271106951a63a104dfc2e70;p=matthieu%2Ffrr.git Revert "lib: Attach stdout to child only if --log=stdout and stdout FD is a tty" This reverts commit 0e3c5e8e5907321b35201f0985c1d3f4a1b0e639. (cherry picked from commit 6a36b9ef49bfce59a7e674df233265da6d275257) --- diff --git a/lib/libfrr.c b/lib/libfrr.c index 3187d8d4b6..33237df5fc 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -1108,12 +1108,9 @@ static void frr_terminal_close(int isexit) * don't redirect when stdout is set with --log stdout */ for (fd = 2; fd >= 0; fd--) - if (logging_to_stdout && isatty(fd) && - fd == STDOUT_FILENO) { - /* Do nothing. */ - } else { + if (isatty(fd) && + (fd != STDOUT_FILENO || !logging_to_stdout)) dup2(nullfd, fd); - } close(nullfd); } } @@ -1199,12 +1196,9 @@ void frr_run(struct event_loop *master) * stdout */ for (fd = 2; fd >= 0; fd--) - if (logging_to_stdout && isatty(fd) && - fd == STDOUT_FILENO) { - /* Do nothing. */ - } else { + if (isatty(fd) && + (fd != STDOUT_FILENO || !logging_to_stdout)) dup2(nullfd, fd); - } close(nullfd); }