Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7034935

Partial backport of Process.exec fixes from JDK7 to JDK6

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6u21
    • Fix Version/s: 6u23
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b02
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      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);
      >

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dholmes David Holmes
                Reporter:
                dholmes David Holmes
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: