Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 93001df

Browse files
committed
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.
1 parent 799c0d3 commit 93001df

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/backend/postmaster/syslogger.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.55 2010/01/02 16:57:51 momjian Exp $
21+
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.56 2010/04/01 20:12:22 heikki Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -194,9 +194,12 @@ SysLoggerMain(int argc, char *argv[])
194194
*/
195195
close(fileno(stdout));
196196
close(fileno(stderr));
197-
dup2(fd, fileno(stdout));
198-
dup2(fd, fileno(stderr));
199-
close(fd);
197+
if (fd != -1)
198+
{
199+
dup2(fd, fileno(stdout));
200+
dup2(fd, fileno(stderr));
201+
close(fd);
202+
}
200203
}
201204

202205
/*

0 commit comments

Comments
 (0)