Setting termios VMIN > 0 and VTIME > 0 on non blocking file

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Mar 17 12:16:03 GMT 2020


Hi Åke,

On Mar 16 10:35, Corinna Vinschen wrote:
> On Mar 14 11:36, Åke Rehnman via Cygwin wrote:
> > On 2020-03-14 11:23, Åke Rehnman wrote:
> > > > > BTW there is a gremlin in the "else if (ev)" line....
> > > > A gremlin?  Would you mind to explain?  Btw., if you find a bug
> > > > in the code, we do take patches :) https://cygwin.com/contrib.html
> > > If we have an error event in ev it will make a blocking read even if
> > > VTIME==0.
> 
> Ah, yeah, I was aware of that, I just ignored it for now since I'm not
> sure what the best way to handle that is.
> 
> Two options come to mind, either ignoring these errors entirely, or
> returning -1 with errno set to EIO, along the lines of the Linux test
> for tty_io_error() at the start of tty_read.
> 
> However, I have a sinking feeling that the function needs a rewrite
> anyway.
> 
> For instance, consider reading in blocking mode, which may result in
> running the for loop more than once.  If the first loop successfully
> read 4 bytes, and the second loop runs into an error from
> ClearCommError, the function will return -1 with errno set, completely
> ignoring the fact that 4 bytes have been read already.
> 
> It should return 4 in this case, and only the next run of
> fhandler_serial::raw_read *might* return -1.
> 
> This code really shows its age...

I have revamped the fhandler_serial::raw_read function, but I need
somebody for testing.  Any chance you volunteer for that job?
We may need a couple of days to iron out all problems, but I think
the code is more sound now than the original function.  I even
added a couple of comments to the code (*gasp*) so there's stuff
to discuss and to see why I did it that way.

For a quicker turn around we can also use Freenode IRC, see
https://cygwin.com/irc.html

Interested?


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20200317/625a9f72/attachment.sig>


More information about the Cygwin mailing list