-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?
}