Runtime.exec() 死锁?
代码如下,请高人指点,在output.readLine()无限等待,不知何故.
public int runCommand(String command)throws IOException {
try {
logger.debug("enter OPMNUtil runCommand....");
this.command=command;
logger.debug("command----\n"+this.command);
Process process = Runtime.getRuntime().exec(this.command);
BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader error = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String line=null;
while((line=output.readLine())!=null)
{
logger.debug("output is----"+line);
}
while((line=error.readLine())!=null)
{
logger.debug("error is----"+line);
}
int exitValue=process.exitValue();
//int exitValue = process.waitFor();
logger.debug("waitcode---------"+exitValue);
return exitValue;
}
catch(IOException e){
throw new IOException();
}
catch (Exception e) {
e.printStackTrace();
return -1000;
}
}