termios VTIME and VMIN prevent SIGALRM from interrupting read

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Oct 25 08:36:00 GMT 2012

On Oct 23 16:27, J. L. Sloan wrote:
> If I use termios(3) to set VTIME and VMIN to values greater than zero for
> a serial port, I can no longer interrupt a read(2) against the descriptor
> with SIGALRM. Replacing read(2) with nanosleep(2) yields EINTR as
> expected. Not setting VTIME and VMIN, read(2) yields EINTR as desired.
> Test program and cygcheck output attached. Could be this is intended
> behavior. It seems more likely that this is a bug in the driver for my
> USB-to-serial adapter. Cygwin 1.7.17 snapshot 2012-10-16.

VMIN shouldn't have any influence on that behaviour, in theory.  If you
use VTIME values > 0, the Cygwin code doesn't use it's own interruptible
wait routine, but rather calls ReadFile directly and relies on OS timeout
handling.  So, yes, it's kind of expected right now.

I think it should be possible to rewrite the VTIME behaviour so that
it doesn't rely on the OS timeout but instead adds a timer to the
interruptible wait.  Adding the timer is pretty simple, but changing
the setting of the SetCommTimeouts values might be tricky.  See
especially the VMIN/VTIME comment deep down in fhandler_serial::tcsetattr().


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

More information about the Cygwin mailing list