]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 15 Nov 2016 20:24:16 +0000 (22:24 +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 8fd4cb77d27f22564b9f95d39349e9110df5e945..9e54896aedd55b830882e971b52007f7cde3705c 100644 (file)
@@ -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);