|
42 | 42 | * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
43 | 43 | * Portions Copyright (c) 1994, Regents of the University of California
|
44 | 44 | *
|
45 |
| - * $Header: /cvsroot/pgsql/src/bin/initdb/initdb.c,v 1.8 2003/11/14 17:19:35 tgl Exp $ |
| 45 | + * $Header: /cvsroot/pgsql/src/bin/initdb/initdb.c,v 1.9 2003/11/14 17:30:41 tgl Exp $ |
46 | 46 | *
|
47 | 47 | *-------------------------------------------------------------------------
|
48 | 48 | */
|
@@ -204,22 +204,24 @@ static void *xmalloc(size_t);
|
204 | 204 |
|
205 | 205 | #definePG_CMD_OPEN \
|
206 | 206 | do { \
|
207 |
| - pg = popen(cmd,PG_BINARY_W); \ |
208 |
| - if (pg == NULL) \ |
209 |
| -exit_nicely(); \ |
| 207 | +fflush(stdout); \ |
| 208 | +fflush(stderr); \ |
| 209 | +pg = popen(cmd, PG_BINARY_W); \ |
| 210 | +if (pg == NULL) \ |
| 211 | +exit_nicely(); \ |
210 | 212 | } while (0)
|
211 | 213 |
|
212 | 214 | #definePG_CMD_CLOSE \
|
213 | 215 | do { \
|
214 |
| -if ((pclose(pg) >> 8) & 0xff) \ |
215 |
| -exit_nicely(); \ |
| 216 | +if ((pclose(pg) >> 8) & 0xff) \ |
| 217 | +exit_nicely(); \ |
216 | 218 | } while (0)
|
217 | 219 |
|
218 | 220 | #definePG_CMD_PUTLINE \
|
219 | 221 | do { \
|
220 |
| -if (fputs(*line, pg) < 0) \ |
221 |
| -exit_nicely(); \ |
222 |
| -fflush(pg); \ |
| 222 | +if (fputs(*line, pg) < 0) \ |
| 223 | +exit_nicely(); \ |
| 224 | +fflush(pg); \ |
223 | 225 | } while (0)
|
224 | 226 |
|
225 | 227 | #ifndefWIN32
|
@@ -862,6 +864,10 @@ find_postgres(char *path)
|
862 | 864 |
|
863 | 865 | snprintf(cmd,sizeof(cmd),"\"%s/postgres\" -V 2>%s",path,DEVNULL);
|
864 | 866 |
|
| 867 | +/* flush output buffers in case popen does not... */ |
| 868 | +fflush(stdout); |
| 869 | +fflush(stderr); |
| 870 | + |
865 | 871 | if ((pgver=popen(cmd,"r"))==NULL)
|
866 | 872 | returnFIND_EXEC_ERR;
|
867 | 873 |
|
|