+static bool
+write_buf (const char *buf, int fdout, ssize_t remain)
+{
+ const char *p = buf;
+
+ do {
+ ssize_t written = write (fdout, p, remain);
+ if (written < 0 && errno == EINTR)
+ continue;
+ if (written <= 0) {
+ fprintf (stderr, "Error: writing to temporary file: %s",
+ strerror (errno));
+ return false;
+ }
+ p += written;
+ remain -= written;
+ } while (remain > 0);
+ return true;
+}
+