This is the mail archive of the
cygwin
mailing list for the Cygwin project.
1.7.0: read() blocking with VMIN = VTIME = 0
- From: daniel åkerud <daniel dot akerud at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Tue, 28 Jul 2009 13:00:09 +0200
- Subject: 1.7.0: read() blocking with VMIN = VTIME = 0
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@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.
Best Regards,
Daniel
--
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