From: Denys Vlasenko Date: Fri, 14 Jul 2017 12:22:09 +0000 (+0200) Subject: libbb: safe_write should not return EINTR X-Git-Tag: 1_28_0~406 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a03ac6067764549f4ae25f9a34e1ee9b0d2bb4f2;p=oweals%2Fbusybox.git libbb: safe_write should not return EINTR Signed-off-by: Denys Vlasenko --- 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; }