-1
如果一个进程是通过java runtime.exec(通过ssh)启动的,你如何回到这个进程来杀死它(通过ssh)?有没有办法一旦启动就获得被调用的进程的PID?通过ssh发送“kill”是获得PID的唯一途径吗?如何杀死一个使用java api的远程机器进程
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?
}