Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Check if process is still running from ProcessBuilder

807580Jan 14 2010 — edited Jan 14 2010
ProcessBuilder pb = new ProcessBuilder(currentlyProcessing).redirectErrorStream(true);
                Process p = pb.start();
                p.waitFor();
Hi above is my code. currentlyProcess==/blah/hoho.sh

and hoho.sh just sleeps for 10 seconds

The issue I am having is how do we determine if the process is still running? I am assuming that another thread has been spawned to run the process hence p.waitFor() would pretty much return 0 the moment it executes the command.

I would like to open processA and once processA have completed, run processB and once processB have completed run processC etc etc

Thank you in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 11 2010
Added on Jan 14 2010
6 comments
818 views