Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81e51dd

Browse files
committed
Add fflush() before popen() calls; avoids any possible problem with
double or out-of-sequence output with child process.
1 parent0104fc1 commit81e51dd

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

‎src/bin/initdb/initdb.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
4343
* Portions Copyright (c) 1994, Regents of the University of California
4444
*
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 $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -204,22 +204,24 @@ static void *xmalloc(size_t);
204204

205205
#definePG_CMD_OPEN \
206206
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(); \
210212
} while (0)
211213

212214
#definePG_CMD_CLOSE \
213215
do { \
214-
if ((pclose(pg) >> 8) & 0xff) \
215-
exit_nicely(); \
216+
if ((pclose(pg) >> 8) & 0xff) \
217+
exit_nicely(); \
216218
} while (0)
217219

218220
#definePG_CMD_PUTLINE \
219221
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); \
223225
} while (0)
224226

225227
#ifndefWIN32
@@ -862,6 +864,10 @@ find_postgres(char *path)
862864

863865
snprintf(cmd,sizeof(cmd),"\"%s/postgres\" -V 2>%s",path,DEVNULL);
864866

867+
/* flush output buffers in case popen does not... */
868+
fflush(stdout);
869+
fflush(stderr);
870+
865871
if ((pgver=popen(cmd,"r"))==NULL)
866872
returnFIND_EXEC_ERR;
867873

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp