[vox-tech] stdout

Jeff Newmiller vox-tech@lists.lugod.org
Mon, 27 Oct 2003 22:35:19 -0800 (PST)


On Tue, 28 Oct 2003, Julie Russell wrote:

> Hi Everyone,
> 
> I am writing a C++ application using x11 developing on SuSE 8.2 and suddenly
> my stdout (cout and cerr) are not outputting to the console, or piping to a
> file. Has anyone ever experienced this before? I am baffled!

Standard C streams (STDIN/STDOUT/STDERR) and C++ iostreams (cin/cout/cerr)
involve the use of in-process data structures that your program can
demolish if pointers get loose.  Demolished data structures can cause a
wide variety of symptoms... failure to send any data to the system calls
seems like a pretty believable result of corruption of cout and cerr.

As Mark suggests, writing binary data to stdout can activate odd behavior
in terminal emulation code.  However, it sounds like you can't even get
anything through redirection, so this seems less likely in this case.

Finding these kinds of bugs can be frustrating, particularly if your
program frequently changes the data structures (writes data to cout/cerr).
Sometimes you can use watchpoints on the data in gdb, sometimes you just
have to sprinkle code with output statements (be sure to use the
"endl" object to force buffer flushes).

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------