From owner-freebsd-questions Sun Oct 8 18:23:30 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id SAA17219 for questions-outgoing; Sun, 8 Oct 1995 18:23:30 -0700 Received: from mail.telstra.com.au (mail.telstra.com.au [192.148.160.10]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id SAA17209 for ; Sun, 8 Oct 1995 18:22:59 -0700 Received: from mail_gw.fwall.telecom.com.au(192.148.147.10) by mail via smap (V1.3) id sma024858; Mon Oct 9 11:20:39 1995 Received: from cdn_mail.dn.itg.telecom.com.au(144.135.109.134) by mail_gw.telecom.com.au via smap (V1.3) id sma011348; Mon Oct 9 11:19:54 1995 Received: from rodin.cssc-syd.tansu.com.au (rodin.cssc-syd.tansu.com.au [149.135.252.15]) by cdn_mail.dn.itg.telecom.com.au (8.6.11/8.6.9) with ESMTP id LAA19253 for ; Mon, 9 Oct 1995 11:19:53 +1000 Received: from crab.cssc-syd.tansu.com.au (crab.ind.tansu.com.au [149.135.100.23]) by rodin.cssc-syd.tansu.com.au (8.6.11/8.6.9) with ESMTP id LAA02744 for ; Mon, 9 Oct 1995 11:19:46 +1000 Received: from kiwi.cssc-syd.tansu.com.au (raoul@kiwi.cssc-syd.tansu.com.au [149.135.104.48]) by crab.cssc-syd.tansu.com.au (8.6.9/8.6.9) with ESMTP id LAA24015; Mon, 9 Oct 1995 11:19:42 +1000 Received: (raoul@localhost) by kiwi.cssc-syd.tansu.com.au (8.6.9/8.6.9) id LAA07559; Mon, 9 Oct 1995 11:19:40 +1000 Message-Id: <199510090119.LAA07559@kiwi.cssc-syd.tansu.com.au> Subject: Question on read syscall on serial port To: freebsd-questions@freebsd.org Date: Mon, 9 Oct 1995 11:19:40 +1000 (EST) From: raoul@cssc-syd.tansu.com.au (Raoul Golan) X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1684 Sender: owner-questions@freebsd.org Precedence: bulk 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 call). 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) { sigblock(sigmask(SIGTERM)); intTERM(); /*NOTREACHED*/ } else if (cnt == 0 && errno == ENOENT) { kill(getppid(),SIGUSR1); sigblock(sigmask(SIGTERM)); intTERM(); /*NOTREACHED*/ } else { printf("%d %d\r",cnt,errno); fflush(stdout); } continue; } /* end */ Thanks, Raoul.