postgres.git / summary / log / commit / refs
commit b0a3d7e47cdff59f363361798b920ba7cb73f447
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Thu Apr 01 20:12:28 2010 +0000
First released in: 9.0.0, 8.2.17, 8.3.11, 8.4.4
Don't pass an invalid file handle to dup2(). That causes a crash on
Windows, thanks to a feature in CRT called Parameter Validation.
Backpatch to 8.2, which is the oldest version supported on Windows. In
8.2 and 8.3 also backpatch the earlier change to use DEVNULL instead of
NULL_DEV #define for a /dev/null-like device. NULL_DEV was hard-coded to
"/dev/null" regardless of platform, which didn't work on Windows, while
DEVNULL works on all platforms. Restarting syslogger didn't work on
Windows on versions 8.3 and below because of that.
src/backend/postmaster/syslogger.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index 89f2beb6aca..b58cdf670e7 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -18,7 +18,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.51.2.1 2009/11/19 02:45:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.51.2.2 2010/04/01 20:12:28 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -194,9 +194,12 @@ SysLoggerMain(int argc, char *argv[])
*/
close(fileno(stdout));
close(fileno(stderr));
- dup2(fd, fileno(stdout));
- dup2(fd, fileno(stderr));
- close(fd);
+ if (fd != -1)
+ {
+ dup2(fd, fileno(stdout));
+ dup2(fd, fileno(stderr));
+ close(fd);
+ }
}
/*
[parent: 9b69647824b8]