changeset 19604:c996bc091c6b

master: Do not close stdout if going foreground 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.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 18 Jan 2016 15:50:23 +0200
parents 8a8dfd61d0d2
children d80976d7fec0
files src/master/main.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/main.c	Thu Jan 21 13:59:31 2016 +0200
+++ b/src/master/main.c	Mon Jan 18 15:50:23 2016 +0200
@@ -838,8 +838,9 @@
 			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 =