• Post Reply Bookmark Topic Watch Topic
  • New Topic

App hung at waitFor() method.  RSS feed

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My app never returns from the waitFor method.
The command is a bcp from a file to a Sybase table.
Here is my code:
Runtime myRun = Runtime.getRuntime();
Process p = null;
try {
p = myRun.exec(cmdline);
} catch(IOException ioe){
System.out.println("Exec failed: " + ioe);
}
int completeStatus = 0;
try {
p.waitFor();
//never gets here!!!
completeStatus = p.exitValue();
} catch(InterruptedException ie){
System.out.println("Exec Interrupted: " + ie);
}
 
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what does cmdline DO? It looks like it is still doing it . . .
 
Rob Levo
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Cindy Glass:
So what does cmdline DO? It looks like it is still doing it . . .

Cindy,
It is a bcp command that runs fine and completes from a command prompt.
It is behaving differently when called from the Java app. You are right, of course, that the app does not think it is completed, but I have zero idea why. The database table that was being populated is completely filled with the full contents of the file.
What could be causing the hangup? Need help bigtime.
Thanks.
 
Rob Levo
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have now read on some forums that the hanging problem at the waitFor is typical, and that the resolution is to clear out streams before invoking waitFor.
However, I could not find specifics on clearing streams.
Can anybody help here?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!