Skip to content

Commit

Permalink
lib: Attach stdout to child only if --log=stdout and stdout FD is a tty
Browse files Browse the repository at this point in the history
Prior to this commit stdout of a process started in a daemon mode was
attached to a calling process.
As a result a calling process hung for infinity.

Signed-off-by: Vladislav Odintsov <[email protected]>
  • Loading branch information
odivlad committed Sep 4, 2024
1 parent 7ba895f commit 8f0fafd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/libfrr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,8 @@ 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)
dup2(nullfd, fd);
close(nullfd);
}
Expand Down Expand Up @@ -1213,8 +1213,8 @@ 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)
dup2(nullfd, fd);
close(nullfd);
}
Expand Down

0 comments on commit 8f0fafd

Please sign in to comment.