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

(process) Need combined stderr/stdout streams

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.1
    • core-libs
    • None
    • generic
    • generic

      The fact that the stderr and stdout that one gets from a Process are
      separate is a design disaster!

      In almost all situations the output is
      combined at the source and the ordering of output from the child is preserved.
      These common situations are: starting something under a pty in order to
      run under a terminal emulator and doing >& (csh) redirection.

      As it is, by the time the separate stderr and stdout get through
      the OS buffers and the JDK recommended BufferedStream buffers the
      ordering is completely broken up. (It's ironic how the JDK docs
      recommends that buffering is better)

      As a practical example, we're extending netbeans into a replacement for
      the C++ workshop. Naturally it has to capture and display 'make' output,
      except that make output, and the output of the compilers running under
      it is a mix of stdout and stderr so I've see situations where the
      error messages appear _before_ the compiler cmdline echo.

      One can resort to workarounds like this:

       | > String [] args = new String[3];
       | > args[0] = "/bin/sh"; // NOI18N
       | > args[1] = "-c"; // NOI18N
       | > args[2] = "/usr/ccs/bin/make 2>&1"; // NOI18N
       | > Process proc = rt.exec(args);
       | >
       | > Note the 2>&1 above.

      But we'd rather Runtime.exec() have a flag where you can ask for
      the two streams to be merged at the source.

      The availability of such a flag will also dramatically reduce the potential
      for deadlocks alluded to in the JDK docs for Process.getErrorStream.



            martin Martin Buchholz
            isoleima Ivan Soleimanipour (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: