Unable to start process using Runtime - Solved
Hi, I have been trying to using OpenJDK BSD to run Eclipse and Netbeans. I have been successful in both, but it was not very useful as I there was no way to actually run my code from within the IDEs. There is an issue with OpenJDK for BSD being unable to start a process. After many compiles and narrowing the problem down to the closeDescriptors I was able to find this posting that explains why it doesn't work and some history to it. Most importantly, it also has the fix. http://www.mavetju.org/mail/view_message.php?list=freebsd-java&id=2564148 Applying the patch allows OpenJDK to spawn processes on OS X. Hopefully it will work for all of the BSDs. Michael
Hi Michael, I am the author of the changes to UNIXProcess_md.c. File descriptor 3 is used to communicate any cause of failure back to the parent process. One might think that the openjdk7 code would work on BSD because if the standard way of opening /proc/self/fd, it falls back to closing all descriptors up to sysconf(_SC_OPEN_MAX), which one would think the BSDs would have implemented. In any case, even if the current jdk7 code doesn't work on BSD, it should be easy to create a small patch to it that would be portable to more Unix systems, that could be accepted upstream. I would be willing to review. Martin On Fri, Oct 24, 2008 at 22:15, Michael Franz <mvfranz@gmail.com> wrote:
Hi,
I have been trying to using OpenJDK BSD to run Eclipse and Netbeans. I have been successful in both, but it was not very useful as I there was no way to actually run my code from within the IDEs. There is an issue with OpenJDK for BSD being unable to start a process. After many compiles and narrowing the problem down to the closeDescriptors I was able to find this posting that explains why it doesn't work and some history to it. Most importantly, it also has the fix.
http://www.mavetju.org/mail/view_message.php?list=freebsd-java&id=2564148
Applying the patch allows OpenJDK to spawn processes on OS X. Hopefully it will work for all of the BSDs.
Michael
Martin, Here are the changes that work for OS X. Michael On Sat, Oct 25, 2008 at 12:47 PM, Martin Buchholz <martinrb@google.com>wrote:
Hi Michael,
I am the author of the changes to UNIXProcess_md.c. File descriptor 3 is used to communicate any cause of failure back to the parent process.
One might think that the openjdk7 code would work on BSD because if the standard way of opening /proc/self/fd, it falls back to closing all descriptors up to sysconf(_SC_OPEN_MAX), which one would think the BSDs would have implemented.
In any case, even if the current jdk7 code doesn't work on BSD, it should be easy to create a small patch to it that would be portable to more Unix systems, that could be accepted upstream. I would be willing to review.
Martin
Michael, That looks like a fine patch to the BSD version of UNIXProcess_md.c, but my idea was to avoid having to have a BSD version of this file at all. The hope is eventually to have BSD support integrated into the standard OpenJDK sources, hopefully without special case code specifically for BSDs. Martin On Sat, Oct 25, 2008 at 13:55, Michael Franz <mvfranz@gmail.com> wrote:
Martin,
Here are the changes that work for OS X.
Michael
On Sat, Oct 25, 2008 at 12:47 PM, Martin Buchholz <martinrb@google.com> wrote:
Hi Michael,
I am the author of the changes to UNIXProcess_md.c. File descriptor 3 is used to communicate any cause of failure back to the parent process.
One might think that the openjdk7 code would work on BSD because if the standard way of opening /proc/self/fd, it falls back to closing all descriptors up to sysconf(_SC_OPEN_MAX), which one would think the BSDs would have implemented.
In any case, even if the current jdk7 code doesn't work on BSD, it should be easy to create a small patch to it that would be portable to more Unix systems, that could be accepted upstream. I would be willing to review.
Martin
Martin, I can take a deeper look at the problem and let you know what I come up with. Michael On Sat, Oct 25, 2008 at 10:15 PM, Martin Buchholz <martinrb@google.com>wrote:
Michael,
That looks like a fine patch to the BSD version of UNIXProcess_md.c, but my idea was to avoid having to have a BSD version of this file at all. The hope is eventually to have BSD support integrated into the standard OpenJDK sources, hopefully without special case code specifically for BSDs.
Martin
On Sat, Oct 25, 2008 at 13:55, Michael Franz <mvfranz@gmail.com> wrote:
Martin,
Here are the changes that work for OS X.
Michael
On Sat, Oct 25, 2008 at 12:47 PM, Martin Buchholz <martinrb@google.com> wrote:
Hi Michael,
I am the author of the changes to UNIXProcess_md.c. File descriptor 3 is used to communicate any cause of failure back to the parent process.
One might think that the openjdk7 code would work on BSD because if the standard way of opening /proc/self/fd, it falls back to closing all descriptors up to sysconf(_SC_OPEN_MAX), which one would think the BSDs would have implemented.
In any case, even if the current jdk7 code doesn't work on BSD, it should be easy to create a small patch to it that would be portable to more Unix systems, that could be accepted upstream. I would be willing to review.
Martin
Martin, I think I have found a way we can use the closeDescriptor version that is used by Solaris and Linux for OS X (and probably the other BSD versions). OS X uses /dev/fd instead of /proc/self/fd. I think the other BSD version also use /dev/fd. This patch removes a few functions and hopefully makes the code cleaner. Let me know what you think and if it still works on your platform. Michael On Sun, Oct 26, 2008 at 8:58 AM, Michael Franz <mvfranz@gmail.com> wrote:
Martin,
I can take a deeper look at the problem and let you know what I come up with.
Michael
On Sat, Oct 25, 2008 at 10:15 PM, Martin Buchholz <martinrb@google.com>wrote:
Michael,
That looks like a fine patch to the BSD version of UNIXProcess_md.c, but my idea was to avoid having to have a BSD version of this file at all. The hope is eventually to have BSD support integrated into the standard OpenJDK sources, hopefully without special case code specifically for BSDs.
Martin
On Sat, Oct 25, 2008 at 13:55, Michael Franz <mvfranz@gmail.com> wrote:
Martin,
Here are the changes that work for OS X.
Michael
On Sat, Oct 25, 2008 at 12:47 PM, Martin Buchholz <martinrb@google.com> wrote:
Hi Michael,
I am the author of the changes to UNIXProcess_md.c. File descriptor 3 is used to communicate any cause of failure back to the parent process.
One might think that the openjdk7 code would work on BSD because if the standard way of opening /proc/self/fd, it falls back to closing all descriptors up to sysconf(_SC_OPEN_MAX), which one would think the BSDs would have implemented.
In any case, even if the current jdk7 code doesn't work on BSD, it should be easy to create a small patch to it that would be portable to more Unix systems, that could be accepted upstream. I would be willing to review.
Martin
Hmmmm.... I'm having second thoughts about whether it's worth the effort to try to push bsd support into OpenJDK. That sort of effort would be easier with a configure layer. The IcedTea team is moving in that direction. The most portable approach to finding /proc/self/fd or /dev/fd is to do the detection once at runtime. In pseudocode: final static String fdDir; static { if (new File("/proc/self/fd").isDirectory()) fdDir = "/proc/self/fd"; else if (new File("/dev/fd").isDirectory()) fdDir = "/dev/fd"; else fdDir = null; } And then use that value at runtime. I definitely think getting rid of the heuristic GUESS_FINISHED is worthwhile. Any failures with this heuristic will be rare, unpredictable, and almost undebuggable for mortals. And will only happen in production at 3am. I'm surprised the BSDs don't all have readdir64 and friends. Here's a case where configure would be useful. Or, since a Solaris bug is being worked around, one could make the use of readdir64 conditional on whether compiling for solaris. Martin On Sun, Oct 26, 2008 at 16:52, Michael Franz <mvfranz@gmail.com> wrote:
Martin,
I think I have found a way we can use the closeDescriptor version that is used by Solaris and Linux for OS X (and probably the other BSD versions).
OS X uses /dev/fd instead of /proc/self/fd. I think the other BSD version also use /dev/fd. This patch removes a few functions and hopefully makes the code cleaner.
Let me know what you think and if it still works on your platform.
Michael
On Sun, Oct 26, 2008 at 8:58 AM, Michael Franz <mvfranz@gmail.com> wrote:
Martin,
I can take a deeper look at the problem and let you know what I come up with.
Michael
On Sat, Oct 25, 2008 at 10:15 PM, Martin Buchholz <martinrb@google.com> wrote:
Michael,
That looks like a fine patch to the BSD version of UNIXProcess_md.c, but my idea was to avoid having to have a BSD version of this file at all. The hope is eventually to have BSD support integrated into the standard OpenJDK sources, hopefully without special case code specifically for BSDs.
Martin
On Sat, Oct 25, 2008 at 13:55, Michael Franz <mvfranz@gmail.com> wrote:
Martin,
Here are the changes that work for OS X.
Michael
On Sat, Oct 25, 2008 at 12:47 PM, Martin Buchholz <martinrb@google.com> wrote:
Hi Michael,
I am the author of the changes to UNIXProcess_md.c. File descriptor 3 is used to communicate any cause of failure back to the parent process.
One might think that the openjdk7 code would work on BSD because if the standard way of opening /proc/self/fd, it falls back to closing all descriptors up to sysconf(_SC_OPEN_MAX), which one would think the BSDs would have implemented.
In any case, even if the current jdk7 code doesn't work on BSD, it should be easy to create a small patch to it that would be portable to more Unix systems, that could be accepted upstream. I would be willing to review.
Martin
On Sat, Oct 25, 2008 at 04:55:36PM -0400, Michael Franz wrote:
Martin,
Here are the changes that work for OS X.
FWIW, this is the patch I have locally to make it work. This is also one of the three patches that we couldn't port over from the JRL port since we didn't have an SCA from the contributor. I haven't approached Michiel Boland (who originally came up with it) about doing so, but he may be willing to submit an SCA. Otherwise we'll have to wait until someone does this in a clean room manner (it looks like you obtained it from the mail archives?).
On Sat, Oct 25, 2008 at 12:47 PM, Martin Buchholz <martinrb@google.com>wrote:
I am the author of the changes to UNIXProcess_md.c. File descriptor 3 is used to communicate any cause of failure back to the parent process.
One might think that the openjdk7 code would work on BSD because if the standard way of opening /proc/self/fd, it falls back to closing all descriptors up to sysconf(_SC_OPEN_MAX), which one would think the BSDs would have implemented.
This might be worth looking into. Note that the BSDs haven't mounted /proc by default for several years, so code that expects the existence of /proc is generally not portable to BSD. sysconf(_SC_OPEN_MAX) is present on both FreeBSD 6 and 7. I haven't yet checked Mac OS X or OpenBSD or NetBSD though.
In any case, even if the current jdk7 code doesn't work on BSD, it should be easy to create a small patch to it that would be portable to more Unix systems, that could be accepted upstream. I would be willing to review.
The plan is to merge in all the BSD support at some point. So if doing this another way will make it more acceptable and its feasible to do so then I'm all for it. -- Greg Lewis Email : glewis@eyesbeyond.com Eyes Beyond Web : http://www.eyesbeyond.com Information Technology FreeBSD : glewis@FreeBSD.org
Greg, I did find the original fix in the mail archives. The patch changes a hard coded 3 into a 4 based on an already defined macro/constant. Michael On Sat, Nov 1, 2008 at 1:35 PM, Greg Lewis <glewis@eyesbeyond.com> wrote:
On Sat, Oct 25, 2008 at 04:55:36PM -0400, Michael Franz wrote:
Martin,
Here are the changes that work for OS X.
FWIW, this is the patch I have locally to make it work. This is also one of the three patches that we couldn't port over from the JRL port since we didn't have an SCA from the contributor. I haven't approached Michiel Boland (who originally came up with it) about doing so, but he may be willing to submit an SCA. Otherwise we'll have to wait until someone does this in a clean room manner (it looks like you obtained it from the mail archives?).
On Sat, Nov 1, 2008 at 10:35, Greg Lewis <glewis@eyesbeyond.com> wrote:
On Sat, Oct 25, 2008 at 04:55:36PM -0400, Michael Franz wrote:
Martin,
Here are the changes that work for OS X.
FWIW, this is the patch I have locally to make it work. This is also one of the three patches that we couldn't port over from the JRL port since we didn't have an SCA from the contributor. I haven't approached Michiel Boland (who originally came up with it) about doing so, but he may be willing to submit an SCA. Otherwise we'll have to wait until someone does this in a clean room manner (it looks like you obtained it from the mail archives?).
I've never looked at the actual BSD port sources, so I consider myself JRL-untainted. Sun (and the BSD port team) should make it a priority to "liberate" any source code under JRL so that it can be incorporated into future JDKs. I thought that had already happened for the BSD sources. The other body of work that is currently JRL-encumbered is Ulf Zibis' work. Martin
On Sat, Nov 01, 2008 at 11:27:32AM -0700, Martin Buchholz wrote:
On Sat, Nov 1, 2008 at 10:35, Greg Lewis <glewis@eyesbeyond.com> wrote:
On Sat, Oct 25, 2008 at 04:55:36PM -0400, Michael Franz wrote:
Martin,
Here are the changes that work for OS X.
FWIW, this is the patch I have locally to make it work. This is also one of the three patches that we couldn't port over from the JRL port since we didn't have an SCA from the contributor. I haven't approached Michiel Boland (who originally came up with it) about doing so, but he may be willing to submit an SCA. Otherwise we'll have to wait until someone does this in a clean room manner (it looks like you obtained it from the mail archives?).
I've never looked at the actual BSD port sources, so I consider myself JRL-untainted.
Sun (and the BSD port team) should make it a priority to "liberate" any source code under JRL so that it can be incorporated into future JDKs. I thought that had already happened for the BSD sources. The other body of work that is currently JRL-encumbered is Ulf Zibis' work.
We have. There are three individual fixes that were contributed by different people and some NetBSD work that the author wasn't able to get permission to contribute that remain "unliberated". I suspect the three individuals may be willing to send in an SCA, I just need to send them an email. The NetBSD changes are more problematic, but they are something anyone interested in making things work on NetBSD would probably be able to reconstruct without too much difficulty. The main reason the BSD port of OpenJDK took so long to get under way was getting the legal side of things squared away. A lot of people spent time making sure we got 99% of the existing SCSL, JRL and partner changes in. -- Greg Lewis Email : glewis@eyesbeyond.com Eyes Beyond Web : http://www.eyesbeyond.com Information Technology FreeBSD : glewis@FreeBSD.org
Greg, What publicly available information should we not be looking at? I have not looked at the JDK code until it became the OpenJDK. I found the list email by googling for the specific function that was not working (closeDescriptors). Michael On Sat, Nov 1, 2008 at 3:50 PM, Greg Lewis <glewis@eyesbeyond.com> wrote:
On Sat, Nov 01, 2008 at 11:27:32AM -0700, Martin Buchholz wrote:
On Sat, Nov 1, 2008 at 10:35, Greg Lewis <glewis@eyesbeyond.com> wrote:
On Sat, Oct 25, 2008 at 04:55:36PM -0400, Michael Franz wrote:
Martin,
Here are the changes that work for OS X.
FWIW, this is the patch I have locally to make it work. This is also one of the three patches that we couldn't port over from the JRL port since we didn't have an SCA from the contributor. I haven't approached Michiel Boland (who originally came up with it) about doing so, but he may be willing to submit an SCA. Otherwise we'll have to wait until someone does this in a clean room manner (it looks like you obtained it from the mail archives?).
I've never looked at the actual BSD port sources, so I consider myself JRL-untainted.
Sun (and the BSD port team) should make it a priority to "liberate" any source code under JRL so that it can be incorporated into future JDKs. I thought that had already happened for the BSD sources. The other body of work that is currently JRL-encumbered is Ulf Zibis' work.
We have. There are three individual fixes that were contributed by different people and some NetBSD work that the author wasn't able to get permission to contribute that remain "unliberated". I suspect the three individuals may be willing to send in an SCA, I just need to send them an email. The NetBSD changes are more problematic, but they are something anyone interested in making things work on NetBSD would probably be able to reconstruct without too much difficulty.
The main reason the BSD port of OpenJDK took so long to get under way was getting the legal side of things squared away. A lot of people spent time making sure we got 99% of the existing SCSL, JRL and partner changes in.
-- Greg Lewis Email : glewis@eyesbeyond.com Eyes Beyond Web : http://www.eyesbeyond.com Information Technology FreeBSD : glewis@FreeBSD.org
Greg, Which patch are you referring to? I supplied two patches, one that is like from the mailing list, and another that is completely different. They both solve the same problem, but the second removes a bunch of platform dependent code. I found out about /dev/fd searching for darwin file descriptors and eventually found this posting: http://lists.apple.com/archives/darwin-development/2002/Jan/msg00150.html Michael On Sat, Nov 1, 2008 at 1:35 PM, Greg Lewis <glewis@eyesbeyond.com> wrote:
On Sat, Oct 25, 2008 at 04:55:36PM -0400, Michael Franz wrote:
Martin,
Here are the changes that work for OS X.
FWIW, this is the patch I have locally to make it work. This is also one of the three patches that we couldn't port over from the JRL port since we didn't have an SCA from the contributor. I haven't approached Michiel Boland (who originally came up with it) about doing so, but he may be willing to submit an SCA. Otherwise we'll have to wait until someone does this in a clean room manner (it looks like you obtained it from the mail archives?).
On Sun, Nov 02, 2008 at 09:34:44AM -0400, Michael Franz wrote:
Which patch are you referring to? I supplied two patches, one that is like from the mailing list, and another that is completely different. They both solve the same problem, but the second removes a bunch of platform dependent code.
The one that changes 3 to FAIL_FILENO.
I found out about /dev/fd searching for darwin file descriptors and eventually found this posting: http://lists.apple.com/archives/darwin-development/2002/Jan/msg00150.html
I'll check out your second patch in more detail as soon as I have a chance. It certainly sounds promising.
On Sat, Nov 1, 2008 at 1:35 PM, Greg Lewis <glewis@eyesbeyond.com> wrote:
On Sat, Oct 25, 2008 at 04:55:36PM -0400, Michael Franz wrote:
Martin,
Here are the changes that work for OS X.
FWIW, this is the patch I have locally to make it work. This is also one of the three patches that we couldn't port over from the JRL port since we didn't have an SCA from the contributor. I haven't approached Michiel Boland (who originally came up with it) about doing so, but he may be willing to submit an SCA. Otherwise we'll have to wait until someone does this in a clean room manner (it looks like you obtained it from the mail archives?).
-- Greg Lewis Email : glewis@eyesbeyond.com Eyes Beyond Web : http://www.eyesbeyond.com Information Technology FreeBSD : glewis@FreeBSD.org
participants (3)
-
Greg Lewis
-
Martin Buchholz
-
Michael Franz