This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Noncygwin programs wait for buffer to fill before outputting to ssh

If I run a console application that wasn't built in cygwin when I'm ssh'd into 
a computer, it won't display the program's output until the program ends or 
its buffer fills up. The only other discussion of this problem that I could 
find was in It said 
upgrading to cygwin version 1.5.0-1 would fix the problem, but I already have 

I don't have as much experience with cygwin as I do with VC++, so I dug into 
its libraries. The problem originate's in VC++'s printf and _isatty functions. 
Printf will only flush the buffer after each call if _isatty returns true. 
_isatty will only return true if GetFileType says the file is FILE_TYPE_CHAR. 
This was probably to speed up redirected IO.

I tried to figure out how to create a file of that type, but I couldn't find 
anything short of creating a device driver. Instead, I made a program that 
would hook into the GetFileType function and always return FILE_TYPE_CHAR if 
the handle is one of the standard IO handles from GetStdHandle. I used someone 
else's code from, and it only 
seems to work if msvcrt is statically linked. The other part of the program is 
that it more gracefully handles ctrl-c through ssh, so the program has a 
chance to flush its buffers then, even if msvcrt is dynamically loaded.

It's a bit of a hack, but I couldn't find any other way to do it. You can get 
the source code to my program and the exe from:

To use it do something like:
ForceCharIO.exe ./pktdump_ex.exe

Please tell me if anyone has found a better solution.

 -Lightning strikes
AIM screen name: bleue foudre

Unsubscribe info:
Problem reports:

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