Skip to content

Instantly share code, notes, and snippets.

@lucacesari
Created August 27, 2015 14:26
Show Gist options
  • Save lucacesari/f3caa3cfb731d3a8abd0 to your computer and use it in GitHub Desktop.
Save lucacesari/f3caa3cfb731d3a8abd0 to your computer and use it in GitHub Desktop.
Java Process hanging waitFor() fix
Process p = Runtime.getRuntime().exec("my-long-command");
BufferedInputStream in = new BufferedInputStream(process.getInputStream());
byte[] bytes = new byte[4096];
while (in.read(bytes) != -1) {}
process.waitFor();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment