$OpenBSD: patch-hotspot_src_os_bsd_vm_os_bsd_cpp,v 1.3 2013/02/01 15:34:35 kurt Exp $
--- hotspot/src/os/bsd/vm/os_bsd.cpp.orig	Tue Jan 29 11:05:21 2013
+++ hotspot/src/os/bsd/vm/os_bsd.cpp	Tue Jan 29 11:08:40 2013
@@ -4815,12 +4815,17 @@ int os::available(int fd, jlong *bytes) {
 }
 
 int os::socket_available(int fd, jint *pbytes) {
-  // Bsd doc says EINTR not returned, unlike Solaris
-  int ret = ::ioctl(fd, FIONREAD, pbytes);
+   if (fd < 0)
+     return OS_OK;
 
-  //%% note ioctl can return 0 when successful, JVM_SocketAvailable
-  // is expected to return 0 on failure and 1 on success to the jdk.
-  return (ret < 0) ? 0 : 1;
+   int ret;
+
+   RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret);
+
+   //%% note ioctl can return 0 when successful, JVM_SocketAvailable
+   // is expected to return 0 on failure and 1 on success to the jdk.
+
+   return (ret == OS_ERR) ? 0 : 1;
 }
 
 // Map a block of memory.
