mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Fix unportable setvbuf() usage in initdb.
In yesterday's commit 2dc4f011fd
, I tried
to force buffering of stdout/stderr in initdb to be what it is by
default when the program is run interactively on Unix (since that's how
most manual testing is done). This tripped over the fact that Windows
doesn't support _IOLBF mode. We dealt with that a long time ago in
syslogger.c by falling back to unbuffered mode on Windows. Export that
solution in port.h and use it in initdb.
Back-patch to 8.4, like the previous commit.
This commit is contained in:
@@ -371,6 +371,20 @@ extern int gettimeofday(struct timeval * tp, struct timezone * tzp);
|
||||
#define closesocket close
|
||||
#endif /* WIN32 */
|
||||
|
||||
/*
|
||||
* On Windows, setvbuf() does not support _IOLBF mode, and interprets that
|
||||
* as _IOFBF. To add insult to injury, setvbuf(file, NULL, _IOFBF, 0)
|
||||
* crashes outright if "parameter validation" is enabled. Therefore, in
|
||||
* places where we'd like to select line-buffered mode, we fall back to
|
||||
* unbuffered mode instead on Windows. Always use PG_IOLBF not _IOLBF
|
||||
* directly in order to implement this behavior.
|
||||
*/
|
||||
#ifndef WIN32
|
||||
#define PG_IOLBF _IOLBF
|
||||
#else
|
||||
#define PG_IOLBF _IONBF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default "extern" declarations or macro substitutes for library routines.
|
||||
* When necessary, these routines are provided by files in src/port/.
|
||||
|
Reference in New Issue
Block a user