[uClibc]patch: Loop on EINTR in stdio
johan.adolfsson at axis.com
johan.adolfsson at axis.com
Mon Jun 11 09:12:02 UTC 2001
Although I agree that goto's often are a bad thing,
I don't think a while(1) , continue and break is
easier to read in this case, hence not less evil ;-)
I just took the goto stuff from glibc and I think it
looks rather nice and clean for this.
/Johan
----- Original Message -----
From: Michael Shmulevich <michaels at jungo.com>
To: Johan Adolfsson <johana at axis.com>; <uclibc at uclibc.org>
Sent: Saturday, June 09, 2001 2:35 AM
Subject: Re: [uClibc]patch: Loop on EINTR in stdio
> To my taste, this goto backward is evil...
> why not
>
> while(1)
> {
> ....
> if(errno == EINTR)
> continue;
> ...
> break;
> }
>
> ----- Original Message -----
> From: "Johan Adolfsson" <johan.adolfsson at axis.com>
> To: <uclibc at uclibc.org>
> Sent: Thursday, June 07, 2001 12:36 PM
> Subject: [uClibc]patch: Loop on EINTR in stdio
>
>
> > The following patch (indentation lost) will loop
> > on EINTR in _uClibc_fread (used by fread, fgets etc.)
> > glibc does that and without it I believe error handling
> > from fgets() etc. is hard or impossible
> > to handle properly.
> >
> > At least I had trouble with earlier version of uC-libc when
> > reading from a pipe to a program - when the program exists,
> > you may get an EINTR and you sometimes looses the last
> > bytes.
> >
> > Does anyone see any problem with this solution?
> >
> > /Johan
> >
> > RCS file: /var/cvs/uClibc/libc/stdio/stdio.c,v
> > retrieving revision 1.23
> > diff -u -p -r1.23 stdio.c
> > --- stdio.c 2001/05/07 20:17:35 1.23
> > +++ stdio.c 2001/06/07 10:17:23
> > @@ -423,8 +423,12 @@ off_t _uClibc_fread(unsigned char *buf,
> > goto FROM_BUF;
> > }
> >
> > +/* Retry if EINTR */
> > +try:
> > len = read(fp->fd, p, (unsigned) bytes);
> > if (len < 0) {
> > + if (errno == EINTR)
> > + goto try;
> > fp->mode |= __MODE_ERR;
> > } else {
> > p += len;
> >
> >
> >
> >
> > _______________________________________________
> > uClibc mailing list
> > uClibc at uclibc.org
> > http://uclibc.org/mailman/listinfo/uclibc
> >
>
More information about the uClibc
mailing list