On Fri, Feb 16, 2001 at 02:21:07PM +1100, Mark Zvolanek wrote:
> I had a similar issue with another inhouse developed DOS based NT
> executable.
> But when out programmer put into his C code 'flush STDOUT' after each printf
> it got fixed.
> So I dont believe it is NT cmd.exe buffering the output of tethereal.
Yeah, it's apparently Microsoft being Unclear On The Concept of ANSI C,
if I understand the page at
http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_crt_setvbuf.htm
correctly.
That's part of the Visual C++ 6.0 documentation online, and it says, of
"setvbuf()":
...
The mode must be _IOFBF, _IOLBF, or _IONBF. If mode is _IOFBF
or _IOLBF, then "size" is used as the size of the buffer. If
mode is _IONBF, the stream is unbuffered and "size" and "buffer"
are ignored. Values for "mode" and their meanings are:
_IOFBF
Full buffering; that is, "buffer" is used as the buffer and
"size" is used as the size of the buffer. If "buffer" is NULL,
an automatically allocated buffer "size" bytes long is used.
_IOLBF
With MS-DOS, the same as _IOFBF.
_IONBF
No buffer is used, regardless of "buffer" or "size".
I'm not sure what that "With MS-DOS" stuff means, given that VC++ 6.0
generates 32-bit code and comes with libraries that are for Win32 -
maybe they mean "in a console window" - but "the same as _IOFBF"
inspires me to ask the authors of the VC++ 6.0 C runtime library "what
part of 'line buffered' did you not understand?" I'll have to see what
my ANSI C standard says about "line buffered"; maybe it really *does*
allow "line buffered" to mean the same thing as "fully buffered", bogus
though that might be.
The only fix, as far as I can tell, would be to set a flag if "-l" is
specified, and have the Tethereal code do "fflush(stdout)" after every
line if that flag is set. This may happen eventually, but it's not
necessarily going to happen soon, so you're probably out of luck for now
using Tethereal in that way (and, unless WinDump works around the
problem in the same way - and I don't see anything in the source that
indicates that it does - WinDump will have the same problem).