我正试图杀死一个分离的屏幕会话。最近我用以下java代码启动了一个屏幕会话:
刚刚创建了一个新的ProcessBuilder:
ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c", "screen -mdS " +
servername + " java " + "-Xms256M -Xmx" + max_ram + "M -jar server.jar
").directory(tempDirectory);
开始新流程
try {
Process p = pb.start(); // start a process
subserver.setProcess(p); // save the process if we need it later again
BufferedReader reader = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
}
但问题是:如何杀死这个新进程?