This is the mail archive of the cygwin@sourceware.cygnus.com 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]

Re: "GetNumberOfConsoleInputEvents" never 0?


Tony FITZPATRICK wrote:
> 
> Sorry, my last posting was lacking some info.
> 
> I am running a vanilla Windows95 on a Pentium and the example program I
> included is even more illuminating if you add a second read.
> 
> #include <stdio.h>
> 
> main()
> {
>   int tty;
>   int space_avail = 128;
>   long chars_avail;
>   unsigned char input[128];
> 
>   tty = fileno (stdin);
>   chars_avail = read (tty, &input[0], space_avail);
>   printf("chars_avail = %d\n", chars_avail);
>   chars_avail = read (tty, &input[0], space_avail);
>   printf("chars_avail = %d\n", chars_avail);
>   return 0;
> }

Hmmm, it might help if you said what is supposed to be interesting
about this, what input you gave it, and what results you got
(I suggest that one should *always* include these in any such report.)
If I hit ^Z\r it says 0, if I hold down a key until bash or cmd
stops echoing, which is 254 chars, and then hit return, it says 128 and
then 127.  Pretty much what I would expect.  If I redirect it from
a file, it says 128 128 unless the file contains \r's, in which case
the number is smaller because cygwin doesn't fill out a buffer that it
has squeezed \r's out of (I consider that a bug, but probably not the
one you are concerned with).  But then, since the console mode
hasn't been set,  GetNumberOfConsoleInputEvents never gets called
at all.  So I added 

  #include <termios.h>

  struct termios t;
  tcgetattr(&t);
  t.c_lflag &= ~ICANON;
  tcsetattr(tty, TCSANOW, &t);

and ran it with STRACE=1 and got

FakeReadFile, GetNumberOfConsoleInputEvents returned = 1

which is expected, since 1 means "it worked" (perhaps you are confused
about that), and then

fhandler_console::FakeReadFile: gnocie found no events

"gnocie" of course stands for GetNumberOfConsoleInputEvents.
So, everything seems to be working as I'd expect here.

This all on NT 4.0 service pack 2 with cygwin.dll b17.1 + various
modifications of my own design :-) that I wouldn't expect to have
any bearing on these results.

--
<J Q B>
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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