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

Commit4511e6c

Browse files
committed
In initdb, ensure stdout/stderr buffering behavior is what we expect.
Since this program may print to either stdout or stderr, the relativeordering of its messages depends on the buffering behavior of those files.Force stdout to be line-buffered and stderr to be unbuffered, ensuringthat the behavior will match standard Unix interactive behavior, evenwhen stdout and stderr are rerouted to a file.Per complaint from Tomas Vondra. The particular case he pointed out isnew in HEAD, but issues of the same sort could arise in any branch withother error messages, so back-patch to all branches.I'm unsure whether we might not want to do this in other client programsas well. For the moment, just fix initdb.
1 parente7a9020 commit4511e6c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎src/bin/initdb/initdb.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3447,6 +3447,15 @@ main(int argc, char *argv[])
34473447
char*effective_user;
34483448
charbin_dir[MAXPGPATH];
34493449

3450+
/*
3451+
* Ensure that buffering behavior of stdout and stderr matches what it is
3452+
* in interactive usage (at least on most platforms). This prevents
3453+
* unexpected output ordering when, eg, output is redirected to a file.
3454+
* POSIX says we must do this before any other usage of these files.
3455+
*/
3456+
setvbuf(stdout,NULL,_IOLBF,0);
3457+
setvbuf(stderr,NULL,_IONBF,0);
3458+
34503459
progname=get_progname(argv[0]);
34513460
set_pglocale_pgservice(argv[0],PG_TEXTDOMAIN("initdb"));
34523461

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp