This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
another oddity with file streams
- To: libstdc++ at sourceware dot cygnus dot com
- Subject: another oddity with file streams
- From: scott snyder <snyder at fnal dot gov>
- Date: Sat, 08 Jan 2000 19:39:12 CST
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