Date: Mon, 27 Aug 2007 21:50:40 +0200 (MEST) From: Michiel Boland <michiel@boland.org> To: Ronald Klop <ronald-freebsd8@klop.yi.org> Cc: bug-followup@FreeBSD.org, freebsd-java@FreeBSD.org Subject: Re: java/115557: jdk1.6.0: Runtime.exec(...) fails always Message-ID: <Pine.GSO.4.64.0708272144291.13767@neerbosch.nijmegen.internl.net> In-Reply-To: <1187200271.50815@guido.klop.ws> References: <1187200271.50815@guido.klop.ws>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0708272144291.13767>
