aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-14 14:22:09 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-14 14:22:09 +0200
commita03ac6067764549f4ae25f9a34e1ee9b0d2bb4f2 (patch)
treeaefa2efa17972508509fea6f24071c9ce1b8db05 /libbb
parentd5b98e2ef4b322c2203d6cd150a3a4080de5e1f4 (diff)
downloadbusybox-a03ac6067764549f4ae25f9a34e1ee9b0d2bb4f2.tar.gz
libbb: safe_write should not return EINTR
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/safe_write.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libbb/safe_write.c b/libbb/safe_write.c
index 8f7628016..aad50f5e0 100644
--- a/libbb/safe_write.c
+++ b/libbb/safe_write.c
@@ -13,9 +13,17 @@ ssize_t FAST_FUNC safe_write(int fd, const void *buf, size_t count)
{
ssize_t n;
- do {
+ for (;;) {
n = write(fd, buf, count);
- } while (n < 0 && errno == EINTR);
+ if (n >= 0 || errno != EINTR)
+ break;
+ /* Some callers set errno=0, are upset when they see EINTR.
+ * Returning EINTR is wrong since we retry write(),
+ * the "error" was transient.
+ */
+ errno = 0;
+ /* repeat the write() */
+ }
return n;
}