"read" bug in Cygwin 1.5.16?
Hi all, I tried to forward this message to the main cygwin list yesterday, but had a little trouble getting it there, probably because I mentioned "xterm" in the subject. I'm trying again in case this is NOT an "X" problem but a base cygwin problem. I have attached the test program xtermbug.c instead of pasting it inline. I hope that is OK for this list. If there is anything I can do to help debug the reason I am seeing this problem, please just tell me what to do. BTW, thanks to all the developers for an awesome product. Regards, Peter Farley --- Peter Farley <[EMAIL PROTECTED]> 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=". 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 __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com /*---*/ /* This is a test program to show a cygwin xterm bug, possibly */ /* in the read function. */ /*---*/ /*---*/ /* Definitions for keyboard input sequences */ /*---*/ #define KBD_DELETE "\x1B[3~" #include #include #include #include #include #include #define MSG_SIZE80 /* Size of one message */ #define CMD_SIZE 32767 /* Length of command line*/ #define BYTE unsigned char int ttyreset = 0; struct termios kbattr; /* Terminal I/O structure*/ /*---*/ /* xterm display subroutine */ /*---*/ void xterm_display (void) { int rc; /* Return code */ int i; /* Array subscripts */ charcmdline[CMD_SIZE+1];/* Command line buffer */ int cmdoff = 0; /* Cursor position in cmdline*/ int cmdlen = 0; /* Number of bytes in cmdline*/ //BYTEc; /* Character work area */ FILE *confp; /* Console file pointer */ size_t kbbufsize = CMD_SIZE; /* Size of keyboard buffer */ char *kbbuf = NULL; /* Keyboard input buffer */ int kblen; /* Number of chars in kbbuf */ int keybfd; /* Keyboard file descriptor */ int maxfd; /* Highest file descriptor */ fd_set readset;/* Select file descriptors */ struct timeval tv; /* Select timeout structure */ int maxdbg = 0; /* Set up the input file descriptors */ confp = stdout; keybfd = STDIN_FILENO; fprintf(confp, "start kbbuf=%8.8X,&kbbuf=%8.8X\n", kbbuf, &kbbuf); /* Obtain storage for the keyboard buffer */ if (!(kbbuf = (char *)malloc (kbbufsize))) { fprintf(stderr, "HHCPN002S Cannot obtain keyboard buffer: %s\n", strerror(errno)); return; } fprintf(confp, "start kbbuf=%8.8X,&kbbuf=%8.8X,*kbbuf=%8.8X\n", kbbuf, &kbbuf, *kbbuf); /* Set screen output stream to fully buffered */ setvbuf (confp, NULL, _IOFBF, 0); /* Put the terminal into cbreak mode */ tcgetattr (keybfd, &kbattr); kbattr.c_lflag &= ~(ECHO | ICANON); kbattr.c_cc[VMIN] = 0; kbattr.c_cc[VTIME] = 0; tcsetattr (keybfd, TCSANOW, &kbattr); ttyreset = 1; fprintf(confp, "Starting while(1) loop.\n"); fflush(confp); /* Process messages and commands */ while (1) { /* Set the file descriptors for select */ FD_ZERO (&readset); FD_SET (keybfd, &readset);
Re: "read" bug in Cygwin 1.5.16?
On Sun, May 01, 2005 at 04:56:13PM -0700, Peter Farley wrote: >Hi all, > >I tried to forward this message to the main cygwin >list yesterday, but had a little trouble getting it >there, probably because I mentioned "xterm" in the >subject. I'm trying again in case this is NOT an "X" >problem but a base cygwin problem. > >I have attached the test program xtermbug.c instead >of pasting it inline. I hope that is OK for this >list. Thanks for the test program. There was a problem with setting VMIN == VTIME == 0 on ttys/ptys. I've just checked in a fix. It will be in today's snapshot, when it shows up: http://cygwin.com/snapshots/ . cgf -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: "read" bug in Cygwin 1.5.16?
Christopher Faylor wrote: > There was a problem with setting VMIN == VTIME == 0 on ttys/ptys. I've > just checked in a fix. It will be in today's snapshot, when it shows > up: http://cygwin.com/snapshots/ . Peter Farley wrote: > kbattr.c_cc[VMIN] = 0; > kbattr.c_cc[VTIME] = 0; If you're always using select() to read, you could set VMIN = 1 as a workaround if you need to support versions of Cygwin prior to the above fix. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: "read" bug in Cygwin 1.5.16?
Thanks Chris. I will try to test the snapshot soon, but I may have some RL events interrupting me before I can do so. I'll report back after testing. Peter --- Christopher Faylor <[EMAIL PROTECTED]> wrote: > On Sun, May 01, 2005 at 04:56:13PM -0700, Peter > Farley wrote: > >Hi all, > > > >I tried to forward this message to the main cygwin > >list yesterday, but had a little trouble getting it > >there, probably because I mentioned "xterm" in the > >subject. I'm trying again in case this is NOT an > "X" problem but a base cygwin problem. > > > >I have attached the test program xtermbug.c instead > >of pasting it inline. I hope that is OK for this > >list. > > Thanks for the test program. > > There was a problem with setting VMIN == VTIME == 0 > on ttys/ptys. I've just checked in a fix. It will > be in today's snapshot, when it shows > up: http://cygwin.com/snapshots/ . > > cgf __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: "read" bug in Cygwin 1.5.16?
Thanks Brian, but I don't think support on earlier versions of cygwin is going to be an issue. There's only one other person who tried and found this same bug, so we're somewhat "rara avis" (rare birds). If the snapshot fix works, I can wait for the release to come out. It isn't that urgent, since my workaround is just to run in a console window instead of an xterm. Thanks again for the help. Peter --- Brian Dessent <[EMAIL PROTECTED]> wrote: > > Christopher Faylor wrote: > > > There was a problem with setting VMIN == VTIME == > 0 on ttys/ptys. I've > > just checked in a fix. It will be in today's > snapshot, when it shows > > up: http://cygwin.com/snapshots/ . > > Peter Farley wrote: > > > kbattr.c_cc[VMIN] = 0; > > kbattr.c_cc[VTIME] = 0; > > If you're always using select() to read, you could > set VMIN = 1 as a workaround if you need to support > versions of Cygwin prior to the above fix. > > Brian __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: "read" bug in Cygwin 1.5.16?
I tried the 20050501 snapshot today. The bug has been squashed. Both the test program and hercules operate correctly in an xterm window with the snapshot version of "cygwin1.dll". Thank you for the fix. I will let the hercules list know that the bug will be resolved in the next release. Regards, Peter --- Peter Farley <[EMAIL PROTECTED]> wrote: > Thanks Chris. I will try to test the snapshot soon, > but I may have some RL events interrupting me before > I > can do so. > > I'll report back after testing. > > Peter > > --- Christopher Faylor > <[EMAIL PROTECTED]> wrote: > > On Sun, May 01, 2005 at 04:56:13PM -0700, Peter > > Farley wrote: > > >Hi all, > > > > > >I tried to forward this message to the main > cygwin > > >list yesterday, but had a little trouble getting > it > > >there, probably because I mentioned "xterm" in > the > > >subject. I'm trying again in case this is NOT an > > "X" problem but a base cygwin problem. > > > > > >I have attached the test program xtermbug.c > instead > > >of pasting it inline. I hope that is OK for this > > >list. > > > > Thanks for the test program. > > > > There was a problem with setting VMIN == VTIME == > 0 > > on ttys/ptys. I've just checked in a fix. It > will > > be in today's snapshot, when it shows > > up: http://cygwin.com/snapshots/ . > > > > cgf > > > __ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > > -- > Unsubscribe info: > http://cygwin.com/ml/#unsubscribe-simple > Problem reports: > http://cygwin.com/problems.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ > > __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/