java/115557: jdk1.6.0: Runtime.exec(...) fails always

Michiel Boland michiel at boland.org
Mon Aug 27 12:50:44 PDT 2007


In jdk 1.6 there is some magic performed via file descriptor 3 in 
j2se/src/solaris/native/java/lang/UNIXProcess_md.c that was not in jdk15. 
The problem is that the closeDescriptors() function in the patchset was 
not updated to take this into account.

diff -ur bsd-jdk16-patches-1.orig/jdk16.patches bsd-jdk16-patches-1/jdk16.patches
--- bsd-jdk16-patches-1.orig/jdk16.patches	2007-07-24 09:05:48.000000000 +0200
+++ bsd-jdk16-patches-1/jdk16.patches	2007-08-27 20:44:20.000000000 +0200
@@ -80764,7 +80764,7 @@
  +static int
  +closeDescriptors(void)
  +{
-+	return _thread_sys_closefrom(3);
++	return _thread_sys_closefrom(FAIL_FILENO + 1);
  +}
  +
  +#elif defined(_ALLBSD_SOURCE)
@@ -80782,7 +80782,7 @@
  +    /*
  +     * BSDNOTE: There's no known way to find list of all open file descriptors
  +     * associated with process in FreeBSD.  Therefore we have to pass from
-+     * fd == 3 to maximum fd per process number.  It's possible to retrive
++     * fd == FAIL_FILENO + 1 to maximum fd per process number.  It's possible to retrive
  +     * max number of fd's with three ways: sysctl(kern.maxfilesperproc),
  +     * getrlimit(RLIMIT_NOFILE) and getdtablesize().  In current implementation
  +     * getdtablesize() returns MIN() of first two ways.
@@ -80797,7 +80797,7 @@
  +    max_fd = getdtablesize();
  +    ebadf = 0;
  +
-+    for (i = 3; i < max_fd; i++) {
++    for (i = FAIL_FILENO + 1; i < max_fd; i++) {
  +	if (close(i) < 0) { ebadf++; } else { ebadf = 0; }
  +	/*
  +         * GUESS_FINISHED subsequent calls to close() returned EBADF, assume


More information about the freebsd-java mailing list