Subject: Re: Blocked I/O on serial ports
To: Ruschmeyer, John <jruschme@att.com>
From: Charles Youse <cyouse@artemis.syncom.net>
List: tech-kern
Date: 08/07/1998 11:47:07
On Fri, 7 Aug 1998, Ruschmeyer, John wrote:

> Now, however, I hit the next problem- open() won't complete unless I use the
> O_NONBLOCK option. I assume that this is because the CM11A is not asserting
> the modem control lines.

> Heyu does not seem to have been written for non-blocked I/O, however. The
> major routines which read the serial port all use unchecked read(2) calls
> which usually return EAGAIN. I have put in result tests and loops (a good
> idea anyway), but it makes the background daemon process very processor
> intensive, looping on tight read loops.

My solution would be to open the device non-blocking (to prevent lack of
carrier from blocking the process), then use termios functions to set  the
CLOCAL bit of termios.c_cflag, close the device, and re-open in blocking
mode.

Chuck