【发布时间】:2011-06-06 19:45:08
【问题描述】:
如果一个进程是通过 java runtime.exec(通过 ssh)启动的,你如何回到这个进程来杀死它(通过 ssh)?有没有办法在启动后获取被调用进程的PID?如果可以获取 PID,是否是通过 ssh 发送“kill”的唯一方法?
Process p;
public void startSomething()
{
String[] cmd = {"/usr/bin/ssh", "remoteIPAdd", "./prog"};
try
{
p = Runtime.getRuntime().exec(cmd);
}
catch(IOException e)
{
System.out.print("Epic Fail");
}
}
public void stopSomething()
{
//p.destroy if local would work but not remotely
//How do I stop the remote process then?
}
【问题讨论】:
标签: java ssh kill runtime.exec