[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] Tar short read

From: Kevin Fox
Subject: Re: [Bug-tar] Tar short read
Date: Tue, 27 Sep 2011 13:05:09 -0700

On Tue, 2011-09-27 at 12:48 -0700, Sergey Poznyakoff wrote:
> Kevin Fox <address@hidden> ha escrit:
> > Thats not how I read that function:
> > size_t safe_rw (int fd, void const *buf, size_t count)
> > {
> >   enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
> >   for (;;)
> >     {
> >       ssize_t result = rw (fd, buf, count);
> >       if (0 <= result)
> >         return result;
> >
> > short read, return right away without looping. I don't believe tar
> You seem to confuse "short reads" with "interrupted reads".  A "short
> read" is when read returns less bytes than requested.  No signals are
> delivered it this case.  An "interrupted read" occurs when a signal is
> delivered while read is in progress.  In that case read returns -1 and
> sets errno to EINTR.  That's exactly what this function is designed to
> handle.

Sorry, that is not what posix and glibc say. A short read may happen as
a result of an interrupt:


There are two cases:
If a read() is interrupted by a signal before it reads any data, it
shall return -1 with errno set to [EINTR].

Case two:
If a read() is interrupted by a signal after it has successfully read
some data, it shall return the number of bytes read.

safe_rw only handles the former, not the latter case, which is what I am
talking about.


> Regards,
> Sergey

reply via email to

[Prev in Thread] Current Thread [Next in Thread]