After researching, I noticed that the βrightβ way to use java ProcessBuilder is to create two more threads to handle the stdout / stderr of the newly created process so that it doesn't hang, as shown here:
javaworld article
But this made me wonder about two questions - 1.) Why are separate processes necessary instead of the parent process gobbling stdout and then stderr sequentially?
2.) Also, if you redirected the threads to both exits to stdout, would it be acceptable only for the parent process to swallow the stdout stream and then not have to worry about deadlocks?
source
share