From: root@jacob.remcomp.fr (root)
Subject: Re: how to do a timeout in getchar
9 Mar 1998 05:06:04 -0800
Message-ID: <m0yBxa6-0002fbC.cygnus.gnu-win32@jacob.remcomp.fr>
References: <EpIC3G.9M0@bbc.com>
Content-Type: text
To: cgf@bbc.com
Cc: gnu-win32@cygnus.com

You can implement a version of getchar that does a non blocking read operation
by opening the file (in this case stdin) with  the FILE_FLAG_OVERLAPPED. In that
case the read returns immediately. You could then loop waiting for a signal,
or other event that would stop the loop, or just a character read.

Another method is to use PeekConsoleInput, in this case you get mouse events,
menu events, focus events, what have you.

Yet another method is the age old _kbhit method: Read only if there is keyboard
input available. This method works only with the keyboard. You can't use it
with a redirected stdin.

All those methods can be used to write a version of getchar that looks after
signals, like non-defined signals under Win32: SIGALRM is one of those.

Since this has only sense if you want Unix-like behaviour, I thought it should
be the job of cygnus to emulate that.

-- 
Jacob Navia	Logiciels/Informatique
41 rue Maurice Ravel			Tel 01 48.23.51.44
93430 Villetaneuse 			Fax 01 48.23.95.39
France
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
