From owner-freebsd-questions Sun Oct 8 20:20:39 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id UAA20971 for questions-outgoing; Sun, 8 Oct 1995 20:20:39 -0700 Received: from ref.tfs.com (ref.tfs.com [140.145.254.251]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id UAA20964 for ; Sun, 8 Oct 1995 20:20:36 -0700 Received: (from julian@localhost) by ref.tfs.com (8.6.11/8.6.9) id UAA14415; Sun, 8 Oct 1995 20:18:30 -0700 From: Julian Elischer Message-Id: <199510090318.UAA14415@ref.tfs.com> Subject: Re: Question on read syscall on serial port To: raoul@cssc-syd.tansu.com.au (Raoul Golan) Date: Sun, 8 Oct 1995 20:18:30 -0700 (PDT) Cc: freebsd-questions@freebsd.org In-Reply-To: <199510090119.LAA07559@kiwi.cssc-syd.tansu.com.au> from "Raoul Golan" at Oct 9, 95 11:19:40 am X-Mailer: ELM [version 2.4 PL24] Content-Type: text Content-Length: 2124 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? Returning 0 bytes on a blocking call is considered "Notification of EOF" This is the logical definition of loss of carrier is it not? you could arange to get a signal possibly.. (I'd have ot go back and look again).. > > 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. > hmm interesting.. lemme see what psix says.. (if anything...) nothing in read() hey are you openning cuax or ttyX?