When launching a process from Java, both stderr and stdout can block on output if I don't read from the pipes. Currently I have a thread that pro-actively reads from one and the main thread blocks on the other.
Is there an easy way to join the two streams or otherwise cause the subprocess to continue while not losing the data in stderr?
Set the redirectErrorStream property on ProcessBuilder to send stderr output to stdout:
You should then create a thread to deal with the process stream, something like the following:
Where InputHandler is defined as:
Alternatively, just create two InputHandlers for the InputStream and ErrorStream. Knowing that the program will block if you don't read them is 90% of the battle :)
Just have two threads, one reading from stdout, one from stderr?