errFinished.set(false);
proc = Runtime.getRuntime().exec(command);
// Just reading from stdout and stderr can block, so we wrap them with
// InputStreamPipe allows them to be nonblocking.
stdinISP = new InputStreamPipe(proc.getInputStream());
stderrISP = new InputStreamPipe(proc.getErrorStream());
stdout = (ReadableByteChannel) stdinISP.getChannel();
stderr = (ReadableByteChannel) stderrISP.getChannel();
readOut = new ReaderThread(stdout, "STDOUT", outFinished);
readErr = new ReaderThread(stderr, "STDERR", errFinished);