This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

another oddity with file streams



hi -

Here's another oddity with file streams in the cvs version
of libstdc++.  (Tested on a gnu/linux-386 platform.)

-- z5.cc -----------------------------------------------------------------
#include <iostream>
#include <unistd.h>

int main ()
{
  std::cerr << "line 1\n";
  std::cerr.flush ();
  write (2, "line 2\n", 7);
  std::cerr << "line 3\n";
  return 0;
}
--------------------------------------------------------------------------

If i just run this with the output going to the terminal, it works fine:

$ ./z5
line 1
line 2
line 3


But if i try to redirect the output to a file, the output from the write()
gets lost:

$ ./z5 >& xx
$ cat xx
line 1
line 3


[This showed up in a C++ program -- itself using iostreams for output --
which was calling an older library written in plain C -- which
was using write (2, ...) to output error messages.]

sss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]