From owner-freebsd-java@FreeBSD.ORG Mon Aug 27 19:50:44 2007 Return-Path: Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC41716A417 for ; Mon, 27 Aug 2007 19:50:44 +0000 (UTC) (envelope-from michiel@boland.org) Received: from neerbosch.nijmegen.internl.net (neerbosch.nijmegen.internl.net [217.149.193.38]) by mx1.freebsd.org (Postfix) with ESMTP id 68C8913C48A for ; Mon, 27 Aug 2007 19:50:44 +0000 (UTC) (envelope-from michiel@boland.org) Received: from neerbosch.nijmegen.internl.net by neerbosch.nijmegen.internl.net via neerbosch.nijmegen.internl.net [217.149.193.38] with ESMTP id l7RJoe7L018192 (8.13.4/1.4); Mon, 27 Aug 2007 21:50:40 +0200 (MEST) Received: from localhost by neerbosch.nijmegen.internl.net via mboland@localhost with ESMTP id l7RJoer6018189 (8.13.4/2.02); Mon, 27 Aug 2007 21:50:40 +0200 (MEST) X-Authentication-Warning: neerbosch.nijmegen.internl.net: mboland owned process doing -bs Date: Mon, 27 Aug 2007 21:50:40 +0200 (MEST) From: Michiel Boland To: Ronald Klop In-Reply-To: <1187200271.50815@guido.klop.ws> Message-ID: References: <1187200271.50815@guido.klop.ws> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: bug-followup@FreeBSD.org, freebsd-java@FreeBSD.org Subject: Re: java/115557: jdk1.6.0: Runtime.exec(...) fails always X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Aug 2007 19:50:44 -0000 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