使用java

时间:2018-04-04 17:33:00

标签: java shell gnu-screen

我正试图杀死一个分离的屏幕会话。最近我用以下java代码启动了一个屏幕会话:

  1. 刚刚创建了一个新的ProcessBuilder:

    ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c", "screen -mdS " + 
    servername + " java " + "-Xms256M -Xmx" + max_ram + "M -jar server.jar 
    ").directory(tempDirectory);
    
  2. 开始新流程

    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();
    }   
    
  3. 但问题是:如何杀死这个新进程?

0 个答案:

没有答案