Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-12-04
5
Medium Priority
?
344 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:Ralf Klatt
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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Six Sigma Control Plans
Screencast - Getting to Know the Pipeline

927 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