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

(process) ProcessBuilder#inheritIO does not work on Windows

    Details

    • Subcomponent:
    • Resolved In Build:
      b110
    • CPU:
      x86
    • OS:
      windows_7
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.7.0_07"
        Java(TM) SE Runtime Environment (build 1.7.0_07-b11)
        Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode, sharing)


        ADDITIONAL OS VERSION INFORMATION :
        Windows 7 64-bit
        Microsoft Windows [Version 6.1.7601]

        A DESCRIPTION OF THE PROBLEM :
        Running an external process using java.lang.ProcessBuilder's inheritIO method to cause the standard streams to be inherited does not work. The external process's output does not appear in the invoking process's output.

        Fails as described on both my Windows 7 64-bit and my Vista 32-bit.
        Works fine on Ubuntu Linux (using "ls" and a few other commands).

        Inheriting via redirectOutput(Redirect.INHERIT) fails too.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Using my little test program (below),
        Run:
          java InheritIO command-words...
        Example:
          java InheritIO fc
          ("fc" is an executable that is on all Windows systems, but use any command that produces output)

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Using the FC command as in my example above, I would expect:
        --------
        FC: Insufficient number of file specifications
        Exit value: -1
        -------
        ACTUAL -
        --------
        Exit value: -1
        -------

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        No error messages.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        class InheritIO {
            public static void main(String[] args) throws Exception {
                int err = new ProcessBuilder(args).inheritIO().start().waitFor();
                System.err.println("Exit value: " + err);
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Revert to the old way of copying the streams myself!

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  igerasim Ivan Gerasimov
                  Reporter:
                  mdave Mukesh Dave (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported: