--- src/backend/postmaster/syslogger.c
+++ src/backend/postmaster/syslogger.c
@@ -184,31 +184,22 @@ SysLoggerMain(int argc, char *argv[])
 
 	init_ps_display("logger process", "", "", "");
 
+	int fd = open(DEVNULL, O_WRONLY, 0);
+	
 	/*
-	 * If we restarted, our stderr is already redirected into our own input
-	 * pipe.  This is of course pretty useless, not to mention that it
-	 * interferes with detecting pipe EOF.	Point stderr to /dev/null. This
-	 * assumes that all interesting messages generated in the syslogger will
-	 * come through elog.c and will be sent to write_syslogger_file.
+	 * The closes might look redundant, but they are not: we want to be
+	 * darn sure the pipe gets closed even if the open failed. We can
+	 * survive running with stderr pointing nowhere, but we can't afford
+	 * to have extra pipe input descriptors hanging around.
 	 */
-	if (redirection_done)
+	close(fileno(stdout));
+	close(fileno(stderr));
+	if (fd != -1)
 	{
-		int			fd = open(DEVNULL, O_WRONLY, 0);
-
-		/*
-		 * The closes might look redundant, but they are not: we want to be
-		 * darn sure the pipe gets closed even if the open failed.	We can
-		 * survive running with stderr pointing nowhere, but we can't afford
-		 * to have extra pipe input descriptors hanging around.
-		 */
-		close(fileno(stdout));
-		close(fileno(stderr));
-		if (fd != -1)
-		{
-			dup2(fd, fileno(stdout));
-			dup2(fd, fileno(stderr));
+		dup2(fd, fileno(stdout));
+		dup2(fd, fileno(stderr));
+		if (fd != fileno(stdout) && fd != fileno(stderr))
 			close(fd);
-		}
 	}
 
 	/*
