我如何使用java api杀死远程机器进程
|
如果一个进程是通过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?
}
没有找到相关结果
已邀请:
1 个回复
硕歌沙
被送入新流程应该可以解决问题。