mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-27 08:32:12 +00:00
lib: Attach stdout to child only if --log=stdout and stdout FD is a tty
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 <vlodintsov@k2.cloud>
(cherry picked from commit 0e3c5e8e59
)
This commit is contained in:
parent
cd82888fe8
commit
b496e4b1df
14
lib/libfrr.c
14
lib/libfrr.c
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user