This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: termios VTIME and VMIN prevent SIGALRM from interrupting read


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
http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/fhandler_serial.cc?rev=1.89&content-type=text/x-cvsweb-markup&cvsroot=src
especially the VMIN/VTIME comment deep down in fhandler_serial::tcsetattr().


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]