]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
master: Remove redundant check to guarantee stdin/stdout/stderr fd existence.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 14 Nov 2016 13:51:45 +0000 (14:51 +0100)
committerGitLab <gitlab@git.dovecot.net>
Mon, 14 Nov 2016 17:37:00 +0000 (19:37 +0200)
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

index ab67dc4dd35133d35f9b103072eacb2bdc449928..ff11f0d5284a58f16e7d9b686452fc51add75220 100644 (file)
@@ -822,12 +822,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);