diff options
author | Denys Vlasenko | 2017-07-14 14:22:09 +0200 |
---|---|---|
committer | Denys Vlasenko | 2017-08-04 02:17:50 +0200 |
commit | 6bb89e1622668f649a94239f4b07aea539b1dad8 (patch) | |
tree | eda94aff1e781793390957ecbde2fe2a1566efff | |
parent | 310bcec4dcfaeaf4afa40a5b03e588fd224aeda3 (diff) | |
download | busybox-6bb89e1622668f649a94239f4b07aea539b1dad8.zip busybox-6bb89e1622668f649a94239f4b07aea539b1dad8.tar.gz |
libbb: safe_write should not return EINTR
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/safe_write.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libbb/safe_write.c b/libbb/safe_write.c index 8f76280..aad50f5 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; } |