Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Oct 1995 11:19:40 +1000 (EST)
From: (Raoul Golan)
Subject:   Question on read syscall on serial port
Message-ID:  <>

Next in thread | Raw E-Mail | Index | Archive | Help
Hello people,

I'm reading from a modem on /dev/cua*.  It's a blocking read,
which means I expect it to wait there until data is available,
or until the modem loses carrier, or until an error occurs.

At the moment, when the modem loses carrier, the read syscall 
returns a count of 0 data read, but it does not set errno to 
anything (it leaves errno with the same value it had before the 

Is there any way (via an ioctl, a fcntl, an stty(?) or via some 
modem configuration parameter) of having the read syscall put 
some value into errno, such as ENOENT or EIO, when the modem
loses carrier?

I ask this because in the tip code there is a loop
that exits only once errno is set to these values.  This
means that after the modem's lost carrier my tip session 
fails to exit.

The code is as follows:

/* while some condition */

                cnt = read(FD, buf, BUFSIZ);
                if (cnt <= 0) {
                        /* lost carrier */
                        if (cnt < 0 && errno == EIO) {
                        } else if (cnt == 0 && errno == ENOENT) {
                        } else {
                                printf("%d %d\r",cnt,errno);
/* end */



Want to link to this message? Use this URL: <>