u8-istream: Retry read upon EINTR.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 14 Jul 2012 18:17:07 +0000 (11:17 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 14 Jul 2012 18:18:11 +0000 (11:18 -0700)
This seems unlikely to be a problem, since we're normally dealing
with regular files, for which reads are uninterruptible, but it
can't hurt.

src/libpspp/u8-istream.c

index 77c14133eabb271da894859345ae73e85a9a65b0..b172b164f5c382c6055c205f0ea4f8e7ccc0f1c8 100644 (file)
@@ -194,8 +194,12 @@ fill_buffer (struct u8_istream *is)
   is->head = is->buffer;
 
   /* Read more input. */
-  n = read (is->fd, is->buffer + is->length,
-            U8_ISTREAM_BUFFER_SIZE - is->length);
+  do
+    {
+      n = read (is->fd, is->buffer + is->length,
+                U8_ISTREAM_BUFFER_SIZE - is->length);
+    }
+  while (n < 0 && errno == EINTR);
   if (n > 0)
     is->length += n;
   return n;