title: how to kill runtime.exec?
body: <p>I use the code below , in my jframe in order to execute a shell script via java program, but when i implement an other method to stop runing process, this method is blocked by th first and i can't stop my program. So i msut kill the new process, the problem is how to get the pid of the process and how to put it in background, in order to kill it.</p>
  
  <pre><code>public static void execShellCmd(String cmd) {
      try {
  
          testPath = getPath();
  
          System.out.println(cmd);
          Runtime runtime = Runtime.getRuntime();
          process = runtime.exec(new String[] { "sh",
                  testPath + "/install.sh", cmd, "&amp;" });
          int exitValue = process.waitFor();
          value = exitValue;
          System.out.println("exit value: " + exitValue);
          BufferedReader buf = new BufferedReader(new InputStreamReader(
                  process.getInputStream()));
          String line = "";
          BufferedWriter bufferedWriter = null;
          while ((line = buf.readLine()) != null) {
              System.out.println("exec response: " + line);
              log = line;
              writeToFile(line);
          }
      } catch (Exception e) {
          System.out.println(e);
      }
  }
  </code></pre>