Solved

waitFor() never returns after creation of a process with Runtime.exec

Posted on 2003-12-04
5
339 Views
Last Modified: 2008-03-17
when I create a process with Runtime.exec, waitFor() never
returns

im trying to use cvs to check out a project. im calling the process from java. app is running on Unix - Solaris. if one file is specified for check out - it's fine
if whole project is not
code :
...............................................................................
p =
Runtime.getRuntime().exec("cvs checkout FipWAR")


try {
if (isOSWindows() == false)
p.waitFor();//hangs over here - never returns
} catch (InterruptedException e) {
p.destroy();
}
............................................................

thank you

0
Comment
Question by:gmeltsin
5 Comments
 
LVL 15

Expert Comment

by:Raisor
ID: 9878360
Hi,

You may try it this way:


        fname = "cvs checkout FipWAR";
        boolean isOsWindows = Env.isOsWindows();

        try
        {
           if (!isOsWindows)
           {
                Process t = Runtime.getRuntime().exec(fname)
                t.waitFor();
            }
        }
        catch(Exception e){
            System.out.println("Error: " +e);
            return "Error";
        }



Best regards, Raisor
0
 
LVL 15

Accepted Solution

by:
jimmack earned 500 total points
ID: 9879248
Just in case it's of any use, here's an article on some of the problems that you get with the exec():

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn different types of Android Layout and some basics of an Android App.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question