diff options
author | kientzle <kientzle@FreeBSD.org> | 2010-05-18 14:11:38 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2010-05-18 14:11:38 +0000 |
commit | f11cb3f4b947ea3d659a1b883a71986d52f3efb7 (patch) | |
tree | d9dfb4417f8788eac18c4b1ff58b471f8d0dce57 /lib | |
parent | 7f3f7db3798a4d71f451d4eede04bcd6f9bec96b (diff) | |
download | FreeBSD-src-f11cb3f4b947ea3d659a1b883a71986d52f3efb7.zip FreeBSD-src-f11cb3f4b947ea3d659a1b883a71986d52f3efb7.tar.gz |
Retry reads that fail with EINTR. This fixes a problem
with bsdtar failing on SIGINT.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libarchive/archive_read_open_fd.c | 12 | ||||
-rw-r--r-- | lib/libarchive/archive_read_open_filename.c | 20 |
2 files changed, 20 insertions, 12 deletions
diff --git a/lib/libarchive/archive_read_open_fd.c b/lib/libarchive/archive_read_open_fd.c index 8a7829b..90e764a 100644 --- a/lib/libarchive/archive_read_open_fd.c +++ b/lib/libarchive/archive_read_open_fd.c @@ -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 diff --git a/lib/libarchive/archive_read_open_filename.c b/lib/libarchive/archive_read_open_filename.c index ec0bb36..3d6c5dc 100644 --- a/lib/libarchive/archive_read_open_filename.c +++ b/lib/libarchive/archive_read_open_filename.c @@ -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 |