如果仅仅是用process.waitFor()的话,如果进程挂起这个将永远得不到返回值,是用捕捉getExitValue异常的办法可以work around
private int myWaitProcessFinish(Process process) throws InterruptedException{
boolean finish = false;
int exitValue = -1;
int timeout = 0;
while(!finish && 60 < timeout++){
try{
exitValue = process.exitValue();
finish = true;
} catch(Exception e) {
Thread.sleep(500);
}
}
return exitValue;
}