Solved

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

Posted on 2003-12-04
5
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

627 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