Subject: Re: how to do a timeout in getchar
From: [email-masked] (root)

9 Mar 1998 05:06:04 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Content-Type: text
To: [email-masked]
Cc: [email-masked]

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
"[email-masked]" with one line of text: "help".