Read the stdOut and the stdErr before waiting for the process exit. Closes #2448.