|
Replies:
1
-
Last Post:
Jul 24, 2006 8:26 AM
by: jchristi
|
|
|
|
|
|
|
InputStream from Runtime.exec hangs under Linuxes
Posted:
Jul 24, 2006 5:59 AM
|
|
|
This is strange, I discovered that if I run a process and get an input stream Runtime.getRuntime().exec().getInputStream() - I can read only the very first line from it or sometimes just nothing.
It actually blocks at native method: at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:194) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read1(BufferedInputStream.java:256) at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
This is 100% reproducible under Linuxes, jdk1.4, runs with no problems on Windows and Macs.
Does anybody have a clue?
|
|
|
|
|
|
|
Re: InputStream from Runtime.exec hangs under Linuxes
Posted:
Jul 24, 2006 8:26 AM
in response to: kirillk
|
|
|
Be sure to get both the input stream and the error stream, and consume/drain both of these.
I've seen that if you dont consume both, on some platforms, the child process will simply hang. If the stderr output of your child process varies in timing/content, this would explain your mention of "Sometimes" in your posting.
-JC
|
|
|
|
|