/** * Attempts to kill the given process */ public static int killProcess(Long pid, String params) { if (pid == null || !isProcessAlive(pid)) { return 0; } if (isWindows) { if ("-9".equals(params)) { params = "/F"; } return killProcessWindows(pid, params); } else { return killProcessUnix(pid, params); } }
/** * Returns the PID for the process; checking first if its still active. * * @return null if the process is no longer active */ public Long getActivePid() throws IOException { ProcessController aController = getController(); Long answer = null; if (aController != null) { answer = aController.getPid(); } if (answer != null) { if (!Processes.isProcessAlive(answer)) { answer = null; } } return answer; } }