Retry reads that fail with EINTR. This fixes a problem

with bsdtar failing on SIGINT.
This commit is contained in:
Tim Kientzle 2010-05-18 14:11:38 +00:00
parent 1dfdc15bb0
commit 50e63ee142
2 changed files with 20 additions and 12 deletions

View file

@ -116,11 +116,15 @@ file_read(struct archive *a, void *client_data, const void **buff)
ssize_t bytes_read;
*buff = mine->buffer;
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
if (bytes_read < 0) {
archive_set_error(a, errno, "Error reading fd %d", mine->fd);
for (;;) {
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
if (bytes_read < 0) {
if (errno == EINTR)
continue;
archive_set_error(a, errno, "Error reading fd %d", mine->fd);
}
return (bytes_read);
}
return (bytes_read);
}
#if ARCHIVE_API_VERSION < 2

View file

@ -160,15 +160,19 @@ file_read(struct archive *a, void *client_data, const void **buff)
ssize_t bytes_read;
*buff = mine->buffer;
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
if (bytes_read < 0) {
if (mine->filename[0] == '\0')
archive_set_error(a, errno, "Error reading stdin");
else
archive_set_error(a, errno, "Error reading '%s'",
mine->filename);
for (;;) {
bytes_read = read(mine->fd, mine->buffer, mine->block_size);
if (bytes_read < 0) {
if (errno == EINTR)
continue;
else if (mine->filename[0] == '\0')
archive_set_error(a, errno, "Error reading stdin");
else
archive_set_error(a, errno, "Error reading '%s'",
mine->filename);
}
return (bytes_read);
}
return (bytes_read);
}
#if ARCHIVE_API_VERSION < 2