- while ((nr = read(fd, fb_buf, BUFSIZ)) > 0)
- for (off = 0; nr; nr -= nw, off += nw, bytes += nw)
- if ((nw = write(outpipe[1], &fb_buf + off, (size_t) nr)) < 0)
- err(1, "writing %d bytes to output pipe", nr);
+
+ while (1) {
+ do {
+ nr = read(fd, fb_buf, buffersize);
+ } while (nr < 0 && errno == EINTR);
+ if (nr <= 0)
+ break;
+ for (off = 0; nr; nr -= nw, off += nw, bytes += nw)
+ if ((nw = write(outpipe[1], fb_buf + off,
+ (size_t) nr)) < 0) {
+ progressmeter(1);
+ err(1, "writing %u bytes to output pipe",
+ (unsigned) nr);
+ }
+ }