On Mon, Jul 18, 2016 at 11:22 AM, walter harms <wha...@bfs.de> wrote:

>
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.2
> -L/home/abuild/rpmbuild/BUILD/bash-4.2/../readline-6.2
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu'
> -DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib
> -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2
> -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g
> -D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -Wuninitialized -Wextra
> -Wno-unprototyped-calls -Wno-switch-enum -Wno-unused-variable
> -Wno-unused-parameter -ftree-loop-linear -pipe -DBNC382214=0 -fprofile-use
> uname output: Linux omnfr121 4.5.0-4.g3d86af7-default #1 SMP PREEMPT Fri
> Mar 18 13:03:45 UTC 2016 (3d86af7) x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-suse-linux-gnu
>
> Bash Version: 4.2
> Patch Level: 47
> Release Status: release
>
> Description:   ordering of printed lines changes when merging stdin/stdout
> and redirecting
>
>
The problem is that buffering of stdout changes depending on where it goes
(line buffered in a terminal, fully buffered in a file), see for instance:

http://www.pixelbeat.org/programming/stdio_buffering/

This should be documented in your libc library.

You could flush stdout in your program, for other workarounds see
http://mywiki.wooledge.org/BashFAQ/009

Reply via email to