IDEA-131748 Stop debug session kills all processes - fixes for IDEA-CR-10579

This commit is contained in:
Egor.Ushakov
2016-05-06 15:54:11 +03:00
parent 8fca2f2755
commit cf9c0a1ef9
2 changed files with 16 additions and 7 deletions
@@ -40,12 +40,12 @@ public class OSProcessUtil {
if (SystemInfo.isWindows) {
try {
if (Registry.is("disable.winp")) {
WinProcessManager.kill(process, true);
return WinProcessManager.kill(process, true);
}
else {
createWinProcess(process).killRecursively();
return true;
}
return true;
}
catch (Throwable e) {
LOG.info("Cannot kill process tree", e);
@@ -15,17 +15,17 @@
*/
package com.intellij.execution.process;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ReflectionUtil;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.WinNT;
import java.io.IOException;
/**
* @author Alexey.Ushakov
*/
public class WinProcessManager {
private static final Logger LOG = Logger.getInstance(WinProcessManager.class);
private WinProcessManager() {}
@@ -57,8 +57,17 @@ public class WinProcessManager {
* @param process Windows process
* @param tree true to also kill all subprocesses
*/
public static void kill(Process process, boolean tree) throws IOException, InterruptedException {
int pid = getProcessPid(process);
Runtime.getRuntime().exec("taskkill /PID " + pid + (tree ? " /t" : "") + " /f").waitFor();
public static boolean kill(Process process, boolean tree) {
try {
int pid = getProcessPid(process);
String command = "taskkill /PID " + pid + (tree ? " /t" : "") + " /f";
LOG.debug(command);
Runtime.getRuntime().exec(command).waitFor();
return true;
}
catch (Exception e) {
LOG.warn(e);
}
return false;
}
}