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
0e3c5e8e5907321b35201f0985c1d3f4a1b0e639)
* 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);
}
}
* 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);
}