From: Timo Sirainen Date: Mon, 14 Nov 2016 13:51:45 +0000 (+0100) Subject: master: Remove redundant check to guarantee stdin/stdout/stderr fd existence. X-Git-Tag: 2.2.27~174 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fd717f41dad3d71435dbca4a05135a34ffe7accc;p=thirdparty%2Fdovecot%2Fcore.git 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. --- 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);