aboutsummaryrefslogtreecommitdiff
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-08-04 02:17:50 +0200
commit6bb89e1622668f649a94239f4b07aea539b1dad8 (patch)
treeeda94aff1e781793390957ecbde2fe2a1566efff
parent310bcec4dcfaeaf4afa40a5b03e588fd224aeda3 (diff)
downloadbusybox-w32-6bb89e1622668f649a94239f4b07aea539b1dad8.tar.gz
busybox-w32-6bb89e1622668f649a94239f4b07aea539b1dad8.tar.bz2
busybox-w32-6bb89e1622668f649a94239f4b07aea539b1dad8.zip
libbb: safe_write should not return EINTR
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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)
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}