我目前正在编写一个需要运行linux rpm
命令的java程序,rpm
安装的一部分会停止启动rpm
命令的jvm。
我尝试使用nohup
和&
运行流程构建器,然后将流程分离无效,尝试使用Runtime.exec()
nohup
也没有成功和&
我已经完成的启动流程的代码发布在下面。
它们总是退出并发出错误,说明正在执行更新的进程已退出,因此rpm
命令失败。
为什么这些调用会产生一个分离的进程失败并在jvm退出时退出?
public static void noWaitrunProcess(String commands[], String commandInputText)
throws InterruptedException {
ProcessInfo processInfo = new ProcessInfo();
BufferedWriter writer = null;
OutputStream outputStream = null;
try {
ProcessBuilder builder = new ProcessBuilder(commands);
builder.redirectErrorStream(true);
Process process = builder.start();
if(commandInputText != null){
outputStream = process.getOutputStream();
writer = new BufferedWriter(new OutputStreamWriter(outputStream));
writer.write(commandInputText);
writer.close();
}
} catch (IOException e) {
processInfo.procOutput = "error running process";
} finally {
if(writer != null)
{
try {
writer.close();
} catch (IOException e) {
}
}
}
}
我正在尝试安装
时收到此错误D: install: waitpid(5668) rc 5668 status f secs 0.099
error: %pre(a[[-3.0-9.160513095338.i686) scriptlet failed, signal 15
error: install: %pre scriptlet failed (2), skipping app-3.0-9.160513095338