Sourav Chandra
Sourav Chandra

Reputation: 1

java.lang.Process.waitFor() is hanging

I am trying to execute below command on Solaris which is hanging.

swmml -l /tmp/swmmlLog.txt -n N1 -e DISPLAY-M3UA-LSET;

;swmml -> perl script.

I tried to flush out the streams/closing the streams. Nothing is working. I tried with both ProcessBBuilder and Runtime.exec() but of no success.

We tried to read from the streams.But the read method is itself hanging. The following code is not printing anything.

 while (true) {
     String s = br.readLine ();
     if (s == null) break;
     System.out.println (s);
 }

Upvotes: 0

Views: 1431

Answers (1)

erickson
erickson

Reputation: 269897

You say that you are flushing and closing the streams, but are you fully reading the content of both standard out and standard error?

A common problem is that the child process blocks because its standard error pipe fills up when the parent Java process neglects to consume its output.

Upvotes: 8

Related Questions