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.
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