JDK-4480528 : (process) Need combined stderr/stdout streams
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.3.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-07-17
  • Updated: 2003-09-10
  • Resolved: 2003-09-10
Related Reports
Duplicate :  
Description
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.




Comments
EVALUATION As part of the changes for adding ProcessBuilder, for bug 4738465: (process) Need to create subprocess environment derived from current environment we are adding the method ProcessBuilder.redirectErrorStream(), which will provide the desired functionality. This bug is therefore closed as a DUP of that bug. ###@###.### 2003-09-09
09-09-2003