Java Bugs - exec bug

The error stream of an exec'd process is not reliably accessible.

This program demonstrates two bugs with the error stream of an exec'd Process.

What the program tries to do is exec a subprocess that writes something to stderr; read that text from the subprocess's error stream and echo it to System.err; and display the return value of the subprocess.

What happens instead, when run using Solaris JDK 1.0.2:

This bug is fixed in JDK 1.1.

View the source code.

% java Bugs.ExecBug
len=9
err = 1!
len=20
cat: cannot open /felen=-2
java.lang.ArrayIndexOutOfBoundsException
	at java.io.BufferedOutputStream.write(BufferedOutputStream.java)
	at java.io.PrintStream.write(PrintStream.java)
	at ExecBug.main(ExecBug.java:37)

Back to bugs.
Back to ACME Java.
Back to ACME Labs.