我有processbuilder
运行.sh script
。它打开了一个终端。我想稍后破坏这个终端。我试过process.destroy()
,但它没有完成这项工作。
代码:
Process p = new ProcessBuilder("/usr/bin/gnome-terminal", "-e", "/home/omar/ros_ws/./baxter2.sh").start();
try {
Thread.sleep(10000); // wait for one second
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
p.destroy();
答案 0 :(得分:0)
try
{
Process[] proc = new Process[2];
proc[0] = new ProcessBuilder("calc.exe").start();
proc[1] = new ProcessBuilder("notepad.exe").start();
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
proc[0].destroy();
proc[1].destroy();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}