From: jqb AT netcom DOT com (Jim Balter) Subject: Re: "GetNumberOfConsoleInputEvents" never 0? 28 Feb 1997 13:39:34 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <33168E4A.6B65.cygnus.gnu-win32@netcom.com> References: <199702272249 DOT XAA05981 AT prat DOT iway DOT fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01Gold (WinNT; I) Original-To: Tony FITZPATRICK Original-CC: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com 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 > > 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 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. -- - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".