]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
master: Do not close stdout if going foreground
authorAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 18 Jan 2016 13:50:23 +0000 (15:50 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 22 Jan 2016 13:52:47 +0000 (15:52 +0200)
This lets one to use /dev/stdout for logging. Mainly
useful for testing purposes where we can generate
log output to stdout and use tee to write it to a
file for later examination.

src/master/main.c

index b26279c8efd0ab4f22d986f6c40ad3bf966660ba..a98a0b4c56fb16d1c7453eaf018c529b13f3241b 100644 (file)
@@ -838,8 +838,9 @@ int main(int argc, char *argv[])
                        t_askpass("Give the password for SSL keys: ");
        }
 
-       if (dup2(null_fd, STDIN_FILENO) < 0 ||
-           dup2(null_fd, STDOUT_FILENO) < 0)
+       if (dup2(null_fd, STDIN_FILENO) < 0)
+               i_fatal("dup2(null_fd) failed: %m");
+       if (!foreground && dup2(null_fd, STDOUT_FILENO) < 0)
                i_fatal("dup2(null_fd) failed: %m");
 
        pidfile_path =