Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Oct 1995 20:18:30 -0700 (PDT)
From:      Julian Elischer <julian@ref.tfs.com>
To:        raoul@cssc-syd.tansu.com.au (Raoul Golan)
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Question on read syscall on serial port
Message-ID:  <199510090318.UAA14415@ref.tfs.com>
In-Reply-To: <199510090119.LAA07559@kiwi.cssc-syd.tansu.com.au> from "Raoul Golan" at Oct 9, 95 11:19:40 am

next in thread | previous 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 
> 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?





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510090318.UAA14415>