This was checked in to gcc.gnu.org on July 25, 2003


--- /home/tromey/OS/rpms/gcc-ssa/gcc/libjava/java/io/natFileDescriptorPosix.cc	2003-06-04 02:44:22.000000000 -0600
+++ libjava/java/io/natFileDescriptorPosix.cc	2003-07-25 17:01:34.000000000 -0600
@@ -105,13 +105,11 @@
 	}
     }
 
-/* FIXME: comment this out until its better tested/implemented
   if ((jflags & SYNC))
     flags |= O_SYNC;
 
   if ((jflags & DSYNC))
     flags |= O_DSYNC;
-*/
 
   int fd = ::open (buf, flags, mode);
   if (fd == -1 && errno == EMFILE)
@@ -152,7 +150,8 @@
 	      iioe->bytesTransferred = r == -1 ? 0 : r;
 	      throw iioe;
 	    }	    
-	  throw new IOException (JvNewStringLatin1 (strerror (errno)));
+	  if (errno != EINTR)
+	    throw new IOException (JvNewStringLatin1 (strerror (errno)));
 	}
     }
   position++;
@@ -180,7 +179,8 @@
 	      iioe->bytesTransferred = written;
 	      throw iioe;
 	    }
-	  throw new IOException (JvNewStringLatin1 (strerror (errno)));
+	  if (errno != EINTR)
+	    throw new IOException (JvNewStringLatin1 (strerror (errno)));
 	}
 
       written += r;
@@ -284,20 +284,26 @@
 java::io::FileDescriptor::read (void)
 {
   jbyte b;
-  int r = ::read (fd, &b, 1);
-  if (r == 0)
-    return -1;
-  if (r == -1)
+  int r;
+  do
     {
-      if (java::lang::Thread::interrupted())
+      r = ::read (fd, &b, 1);
+      if (r == 0)
+	return -1;
+      if (r == -1)
 	{
-	  InterruptedIOException *iioe
-	    = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
-	  iioe->bytesTransferred = r == -1 ? 0 : r;
-	  throw iioe;
+	  if (java::lang::Thread::interrupted())
+	    {
+	      InterruptedIOException *iioe
+		= new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
+	      iioe->bytesTransferred = r == -1 ? 0 : r;
+	      throw iioe;
+	    }
+	  if (errno != EINTR)
+	    throw new IOException (JvNewStringLatin1 (strerror (errno)));
 	}
-      throw new IOException (JvNewStringLatin1 (strerror (errno)));
     }
+  while (r != 1);
   position++;
   return b & 0xFF;
 }
@@ -316,20 +322,26 @@
     return 0;
 
   jbyte *bytes = elements (buffer) + offset;
-  int r = ::read (fd, bytes, count);
-  if (r == 0)
-    return -1;
-  if (r == -1)
-    {    
-      if (java::lang::Thread::interrupted())
+  int r;
+  do
+    {
+      r = ::read (fd, bytes, count);
+      if (r == 0)
+	return -1;
+      if (r == -1)
 	{
-	  InterruptedIOException *iioe
-	    = new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
-	  iioe->bytesTransferred = r == -1 ? 0 : r;
-	  throw iioe;
+	  if (java::lang::Thread::interrupted())
+	    {
+	      InterruptedIOException *iioe
+		= new InterruptedIOException (JvNewStringLatin1 (strerror (errno)));
+	      iioe->bytesTransferred = r == -1 ? 0 : r;
+	      throw iioe;
+	    }
+	  if (errno != EINTR)
+	    throw new IOException (JvNewStringLatin1 (strerror (errno)));
 	}
-      throw new IOException (JvNewStringLatin1 (strerror (errno)));
     }
+  while (r <= 0);
   position += r;
   return r;
 }
