Merged stdout and stderr redirected to a file causes wrong ordering

Bug #1381792 reported by Removed by request
6
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

I'm using Ubuntu 14.10 dev with bash 4.3-11ubuntu1 and if stdout is redirected to a file and stderr is redirected to stdout the order isn't correct anymore. I have written a testcase to demonstrate the problem:

#include <stdio.h>

int main()
{
 short unsigned i;

 for(i = 0; i < 1024; ++i)
 {
  fprintf(stdout, "stdout\n");
  fprintf(stderr, "stderr\n");
 }
 return 0;
}

The code needs to be compiled with gcc for example as "gcc -Wall -pedantic -o test test.c". On executing "./test > test.log 2>&1" I would normally expect that the lines "stdout" and "stderr" are alternating with each other but I'm seeing a few hundred lines "stderr" and then a few hundred lines "stdout" and so on. Interestingly on every try I'm also seeing on line 1171 "sstderr" and on line 1610 "tdout" (these both lines seems to got mixed up).

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.