libc_noux: leave write loop on error

Fixes #3541.
This commit is contained in:
Josef Söntgen 2019-10-14 17:01:47 +02:00 committed by Christian Helmuth
parent f5c5479faa
commit 55ab694d79
1 changed files with 13 additions and 2 deletions

View File

@ -1292,7 +1292,7 @@ namespace {
if (!buf) { errno = EFAULT; return -1; }
/* remember original len for the return value */
int const orig_count = count;
size_t const orig_count = count;
char *src = (char *)buf;
while (count > 0) {
@ -1317,12 +1317,23 @@ namespace {
errno = 0;
break;
}
/* try again */
bool const retry = (errno == EINTR
|| errno == EAGAIN
|| errno == EWOULDBLOCK);
if (errno && retry)
continue;
/* leave writing loop on error */
if (errno)
break;
}
count -= sysio()->write_out.count;
src += sysio()->write_out.count;
}
return orig_count;
return orig_count - count;
}