← Commit list

a03ac6067

Denys Vlasenko
Denys Vlasenko
2017-07-14
SUCCESS Duration: 142s

Subject

libbb: safe_write should not return EINTR

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/safe_write.c+10 -2
@@ -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;
}