Maintenance Notice

The bugs.java.com site will be undergoing maintenance on 15th Dec 2017 21:00 PST to 16th Dec 2017 1:00 AM PST.
JDK-7034935 : Partial backport of Process.exec fixes from JDK7 to JDK6
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6u21
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-04-07
  • Updated: 2011-04-08
  • Resolved: 2011-04-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 6
6u23 b02Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
A number of CRs have made improvements to the Process.exec code in JDK7, primarily for Linux systems and these changes are beneficial on a number of platforms supported by JDK 6. There is no single CR to cover this, but refer to 6850720 and 6853336 to see how the current code came about. See 7020237 for a follow-up bug fix for Solaris 8/9.

Affected file:

src/solaris/native/java/lang/UNIXProcess_md.c
 
The JDK6 code is not exactly the same as JDK7 "due to the fact that the JDK7 version of the Java_java_lang_UNIXProcess_forkAndExec native function now has the ability to pass file descriptors into this routine. The JDK6 version does not support this behavior."

Diffs of JDK7 fix backported to JDK6

646a665
>     int fds[3];
685,686c704,707
<     if ((moveDescriptor(p->in[0], STDIN_FILENO) == -1) ||
<         (moveDescriptor(p->out[1], STDOUT_FILENO) == -1))
---
>     if ((moveDescriptor(p->in[0] != -1 ?  p->in[0] : p->fds[0],
>                         STDIN_FILENO) == -1) ||
>         (moveDescriptor(p->out[1]!= -1 ? p->out[1] : p->fds[1],
>                         STDOUT_FILENO) == -1))
694c715,716
<         if (moveDescriptor(p->err[1], STDERR_FILENO) == -1)
---
>         if (moveDescriptor(p->err[1] != -1 ? p->err[1] : p->fds[2],
>                            STDERR_FILENO) == -1)
795,798c817,818
<                                        jboolean redirectErrorStream,
<                                        jobject stdin_fd,
<                                        jobject stdout_fd,
<                                        jobject stderr_fd)
---
>                                        jintArray std_fds,
>                                        jboolean redirectErrorStream)
802a823
>     jint *fds = NULL;
840,842c861,867
<     if ((pipe(in)  < 0) ||
<         (pipe(out) < 0) ||
<         (pipe(err) < 0) ||
---
>     assert(std_fds != NULL);
>     fds = (*env)->GetIntArrayElements(env, std_fds, NULL);
>     if (fds == NULL) goto Catch;
> 
>     if ((fds[0] == -1 && pipe(in)  < 0) ||
>         (fds[1] == -1 && pipe(out) < 0) ||
>         (fds[2] == -1 && pipe(err) < 0) ||
846a872,874
>     c->fds[0] = fds[0];
>     c->fds[1] = fds[1];
>     c->fds[2] = fds[2];
876,878c904,906
<     (*env)->SetIntField(env, stdin_fd,  IO_fd_fdID, in [1]);
<     (*env)->SetIntField(env, stdout_fd, IO_fd_fdID, out[0]);
<     (*env)->SetIntField(env, stderr_fd, IO_fd_fdID, err[0]);
---
>     fds[0] = (in [1] != -1) ? in [1] : -1;
>     fds[1] = (out[0] != -1) ? out[0] : -1;
>     fds[2] = (err[0] != -1) ? err[0] : -1;
902a931,933
>     if (fds != NULL)
>         (*env)->ReleaseIntArrayElements(env, std_fds, fds, 0);
>

Comments
EVALUATION This fix was putback as part of 6988830.
2011-04-07