diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-14 14:22:09 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-14 14:22:09 +0200 |
commit | a03ac6067764549f4ae25f9a34e1ee9b0d2bb4f2 (patch) | |
tree | aefa2efa17972508509fea6f24071c9ce1b8db05 | |
parent | d5b98e2ef4b322c2203d6cd150a3a4080de5e1f4 (diff) | |
download | busybox-w32-a03ac6067764549f4ae25f9a34e1ee9b0d2bb4f2.tar.gz busybox-w32-a03ac6067764549f4ae25f9a34e1ee9b0d2bb4f2.tar.bz2 busybox-w32-a03ac6067764549f4ae25f9a34e1ee9b0d2bb4f2.zip |
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 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) | |||
13 | { | 13 | { |
14 | ssize_t n; | 14 | ssize_t n; |
15 | 15 | ||
16 | do { | 16 | for (;;) { |
17 | n = write(fd, buf, count); | 17 | n = write(fd, buf, count); |
18 | } while (n < 0 && errno == EINTR); | 18 | if (n >= 0 || errno != EINTR) |
19 | break; | ||
20 | /* Some callers set errno=0, are upset when they see EINTR. | ||
21 | * Returning EINTR is wrong since we retry write(), | ||
22 | * the "error" was transient. | ||
23 | */ | ||
24 | errno = 0; | ||
25 | /* repeat the write() */ | ||
26 | } | ||
19 | 27 | ||
20 | return n; | 28 | return n; |
21 | } | 29 | } |