Mail Archives: cygwin/2009/07/28/07:13:34
On Jul 28 13:00, daniel ?kerud wrote:
> Hello!
>
> With my example program below the read() is blocking even though
> canonical input is set and VMIN = VTIME = 0.
> It is supposed to act in a non-blocking way.
>
> Does not work on:
> CYGWIN_NT-5.0 1.7.0(0.212/5/3) 2009-07-24 09:59
>
> Works on:
> Linux version 2.6.28-13-generic (buildd AT vernadsky) (gcc version 4.3.3
> (Ubuntu 4.3.3-5ubuntu4) ) #45-Ubuntu SMP Tue Jun 30 19:49:51 UTC 2009
>
> Example program:
>
> #include <stdio.h>
> #include <unistd.h>
> #include <termios.h>
>
> int main() {
> char c = 0;
> struct termios term, term_orig;
>
> if(tcgetattr(0, &term_orig)) {
> printf("tcgetattr failed\n");
> return 2;
> }
>
> term = term_orig;
>
> term.c_lflag &= ~ICANON;
> term.c_lflag |= ECHO;
> term.c_cc[VMIN] = 0;
> term.c_cc[VTIME] = 0;
>
> if (tcsetattr(0, TCSANOW, &term)) {
> printf("tcsetattr failed\n");
> return 2;
> }
>
> printf("Calling read (blocks here on cygwin)\n");
> fflush(stdout);
>
> read(0, &c, 1);
>
> printf("Back from read\n");
>
> tcsetattr(0, TCSANOW, &term_orig);
>
> return 0;
> }
>
> Is this supported in Cygwin? The only work around I know for now is to
> do a select() before read()ing.
It's not supported in the normal Windows console mode. It's supported
in the tty emulation, though. This works in the console window as well
by setting the environment variable CYGWIN to contain "tty" before
starting your shell (for instance by adding `set CYGWIN=tty' to your
Cygwin.bat file).
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -