aboutsummaryrefslogtreecommitdiff
path: root/libiberty/simple-object.c
diff options
context:
space:
mode:
Diffstat (limited to 'libiberty/simple-object.c')
-rw-r--r--libiberty/simple-object.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c
index 263d174..5d379d0 100644
--- a/libiberty/simple-object.c
+++ b/libiberty/simple-object.c
@@ -107,8 +107,6 @@ simple_object_internal_write (int descriptor, off_t offset,
const unsigned char *buffer, size_t size,
const char **errmsg, int *err)
{
- ssize_t wrote;
-
if (lseek (descriptor, offset, SEEK_SET) < 0)
{
*errmsg = "lseek";
@@ -116,15 +114,26 @@ simple_object_internal_write (int descriptor, off_t offset,
return 0;
}
- wrote = write (descriptor, buffer, size);
- if (wrote < 0)
+ do
{
- *errmsg = "write";
- *err = errno;
- return 0;
+ ssize_t wrote = write (descriptor, buffer, size);
+ if (wrote == 0)
+ break;
+ else if (wrote > 0)
+ {
+ buffer += wrote;
+ size -= wrote;
+ }
+ else if (errno != EINTR)
+ {
+ *errmsg = "write";
+ *err = errno;
+ return 0;
+ }
}
+ while (size > 0);
- if ((size_t) wrote < size)
+ if (size > 0)
{
*errmsg = "short write";
*err = 0;