2003-02-11 Ranjit Mathew <rmathew@hotmail.com>
authorRanjit Mathew <rmathew@hotmail.com>
Tue, 11 Feb 2003 20:55:26 +0000 (20:55 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Tue, 11 Feb 2003 20:55:26 +0000 (20:55 +0000)
* java/io/natFileDescriptorWin32.cc
(java::io::FileDescriptor::read): Return -1 (EOF) if ReadFile( )
returns with Win32 error code ERROR_BROKEN_PIPE.

From-SVN: r62722

libjava/ChangeLog
libjava/java/io/natFileDescriptorWin32.cc

index 0490ac796fe873c3c19e4d2b888a369f1e3936fa..46dab6412fa2a26bdb0392d0b7c59179c300e248 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-11  Ranjit Mathew  <rmathew@hotmail.com>
+
+       * java/io/natFileDescriptorWin32.cc 
+       (java::io::FileDescriptor::read): Return -1 (EOF) if ReadFile( )
+       returns with Win32 error code ERROR_BROKEN_PIPE.
+
 2003-02-11  Michael Koch  <konqueror@gmx.de>
 
        * Makefile.in
index 4b157f7042c9b8f0df5d315113c00fed86857355..87f94e812223894fadd2c4fa4321051dde997677 100644 (file)
@@ -1,6 +1,7 @@
 // natFileDescriptorWin32.cc - Native part of FileDescriptor class.
 
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002  Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003  Free Software 
+   Foundation, Inc.
 
    This file is part of libgcj.
 
@@ -288,7 +289,13 @@ java::io::FileDescriptor::read(void)
   DWORD read;
 
   if (! ReadFile ((HANDLE)fd, &buf, 1, &read, NULL))
-    throw new IOException (JvNewStringLatin1 (winerr ()));
+    {
+      if (GetLastError () == ERROR_BROKEN_PIPE)
+        return -1;
+      else
+        throw new IOException (JvNewStringLatin1 (winerr ()));
+    }
+
   if (! read)
     return -1;
   else
@@ -313,9 +320,15 @@ java::io::FileDescriptor::read(jbyteArray buffer, jint offset, jint count)
 
   DWORD read;
   if (! ReadFile((HANDLE)fd, bytes, count, &read, NULL))
-    throw new IOException (JvNewStringLatin1 (winerr ()));
+    {
+      if (GetLastError () == ERROR_BROKEN_PIPE)
+        return -1;
+      else
+        throw new IOException (JvNewStringLatin1 (winerr ()));
+    }
 
   if (read == 0) return -1;
+
   return (jint)read;
 }