From: rguenth Date: Fri, 28 Mar 2014 14:05:49 +0000 (+0000) Subject: 2014-03-28 Richard Biener X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=81ad11e32c40b9d53e578054e2885087f347c337;p=binutils-gdb.git 2014-03-28 Richard Biener libiberty/ * simple-object.c (simple_object_internal_read): Handle EINTR and short reads. lto-plugin/ * lto-plugin.c (process_symtab): Handle EINTR and short reads. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208898 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 9dab384ccf2..f20fac0aabb 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2014-03-28 Richard Biener + + * simple-object.c (simple_object_internal_read): Handle + EINTR and short reads. + 2014-03-13 Uros Bizjak * regex.c (bzero) [!_LIBC]: Define without coma expression. diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c index fde3454dd42..263d174051d 100644 --- a/libiberty/simple-object.c +++ b/libiberty/simple-object.c @@ -63,8 +63,6 @@ simple_object_internal_read (int descriptor, off_t offset, unsigned char *buffer, size_t size, const char **errmsg, int *err) { - ssize_t got; - if (lseek (descriptor, offset, SEEK_SET) < 0) { *errmsg = "lseek"; @@ -72,15 +70,26 @@ simple_object_internal_read (int descriptor, off_t offset, return 0; } - got = read (descriptor, buffer, size); - if (got < 0) + do { - *errmsg = "read"; - *err = errno; - return 0; + ssize_t got = read (descriptor, buffer, size); + if (got == 0) + break; + else if (got > 0) + { + buffer += got; + size -= got; + } + else if (errno != EINTR) + { + *errmsg = "read"; + *err = errno; + return 0; + } } + while (size > 0); - if ((size_t) got < size) + if (size > 0) { *errmsg = "file too short"; *err = 0;