read bug in Cygwin xterm window only

Jason Curl j.m.curl@optusnet.com.au
Thu Jun 9 18:56:00 GMT 2005


Peter Farley wrote:
> Hi all,
> 
> The following program demonstrates what looks to me
> like a bug in the "read" function in an xterm (as
> opposed to a Cygwin console window).  To run the test,
> compile with:
> 
> gcc -g -o xtermbug.exe xtermbug.c
> 
> When you run it in a console window, you can enter
> normal keyboard characters, then a return to see
> "cmdline=<what you typed>".  Press the Esc key to exit
> the program.

Unfortunately I'm seeing exactly the same problem too, and have so for 
some time. I've also noticed that a read() giving a particular length 
will ignore the length field and actually read more data in some cases.

I haven't seen these problems under a normal console, nor under xterm on 
other operating systems (e.g. Linux).

> 
> When run in an xterm window, the first keypress causes
> this behavior:
> 
> 1. Select returns with rc = 0 and readset set to
> indicate that a key was received
> 2. "read" returns with kblen = 1 and kbbuf[0] = '\0'
> 3. (1) and (2) repeat forever.
> 
> I put in a "maxdbg" parameter and terminate the
> program after 5 occurrences of this loop.
> 
> This problem was first detected trying to run a copy
> of the hercules IBM mainframe emulator in a Cygwin
> xterm window.  The code below is extracted and
> minimalized as much as possible from the hercules
> keyboard input routine.
> 
> Peter Farley
> 



More information about the Cygwin-xfree mailing list