From fd717f41dad3d71435dbca4a05135a34ffe7accc Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 14 Nov 2016 14:51:45 +0100 Subject: [PATCH] master: Remove redundant check to guarantee stdin/stdout/stderr fd existence. The previous method also wasn't correct, since it was setting close-on-exec flag for the fds. Although this didn't normally make any difference, since stdin & stdout was explicitly dup2()ed to /dev/null and for all except the log process stderr was also being dup2()ed. --- src/master/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/master/main.c b/src/master/main.c index 8fd4cb77d2..9e54896aed 100644 --- a/src/master/main.c +++ b/src/master/main.c @@ -824,12 +824,12 @@ int main(int argc, char *argv[]) i_fatal("Unknown argument: --%s", argv[optind]); } - do { - null_fd = open("/dev/null", O_WRONLY); - if (null_fd == -1) - i_fatal("Can't open /dev/null: %m"); - fd_close_on_exec(null_fd, TRUE); - } while (null_fd <= STDERR_FILENO); + null_fd = open("/dev/null", O_WRONLY); + if (null_fd == -1) + i_fatal("Can't open /dev/null: %m"); + fd_close_on_exec(null_fd, TRUE); + i_assert(null_fd > STDERR_FILENO); + if (pipe(global_master_dead_pipe_fd) < 0) i_fatal("pipe() failed: %m"); fd_close_on_exec(global_master_dead_pipe_fd[0], TRUE); -- 2.47.3