Results 1 to 3 of 3
- 02-09-2010, 04:21 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 29
- Rep Power
- 0
Process.waitFor() method hangs application.
Hi,
I am executing Unix command "ps -ef" from Java using Runtime and Process.waitFor() method as shown in the code below. It works fine on our local enviornment but at the client side application hangs after waitFor() method. What could be the possible reason for this.
boolean exeCommand() {
String command = new String();
String psgOut, pargsOut;
StringTokenizer strtok;
Integer pid;
int i;
Process psg, pargs;
command = "ps -ef";
try {
psg = Runtime.getRuntime().exec(command);
System.out.println("Before waitFor");
i = psg.waitFor();
System.out.println("After waitFor");
if (i != 0) {
return false;
} else {
BufferedReader psgInput = new BufferedReader(
new InputStreamReader(psg.getInputStream()));
while ((psgOut = psgInput.readLine()) != null) {
if (psgOut.contains("test")) {
return true;
}
}
}
} catch (Exception exp) {
System.out.println("Exception");
}
return false;
}
Thanks in Advance.
Simmi
- 02-09-2010, 05:09 AM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,144
- Rep Power
- 5
When Runtime.exec() won't - JavaWorld might help.
- 02-10-2010, 03:35 AM #3
Member
- Join Date
- Apr 2009
- Posts
- 29
- Rep Power
- 0
Similar Threads
-
NetBeans hangs on startup
By peterme in forum NetBeansReplies: 1Last Post: 01-25-2010, 10:22 PM -
How to send keystroke/text to some another application/process
By vinc in forum Advanced JavaReplies: 4Last Post: 11-26-2009, 09:40 AM -
Program hangs
By yuliada in forum Advanced JavaReplies: 2Last Post: 11-11-2009, 03:58 AM -
Discussion: JVM hangs
By Arica in forum Advanced JavaReplies: 5Last Post: 06-29-2009, 04:29 AM -
Disallow doPOST method in Sun Application server
By prakash_sahoo in forum Advanced JavaReplies: 5Last Post: 08-28-2008, 06:54 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks