Skip to content

Commit

Permalink
fallback to default logic if winp fails (IDEA-CR-37392)
Browse files Browse the repository at this point in the history
  • Loading branch information
segrey committed Oct 3, 2018
1 parent 0f0376b commit 3db91ed
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ public static void killProcess(@NotNull Process process) {
public static void killProcess(int pid) {
if (SystemInfo.isWindows) {
try {
if (Registry.is("disable.winp")) {
WinProcessManager.kill(pid, false);
}
else {
createWinProcess(pid).kill();
if (!Registry.is("disable.winp")) {
try {
createWinProcess(pid).kill();
return;
}
catch (Error e) {
LOG.error("Failed to kill process with winp, fallback to default logic", e);
}
}
WinProcessManager.kill(pid, false);
}
catch (Throwable e) {
LOG.info("Cannot kill process", e);
Expand All @@ -80,12 +84,15 @@ public static int getProcessID(@NotNull Process process) {
if (process instanceof WinPtyProcess) {
return ((WinPtyProcess)process).getChildProcessId();
}
if (Registry.is("disable.winp")) {
return WinProcessManager.getProcessId(process);
}
else {
return createWinProcess(process).getPid();
if (!Registry.is("disable.winp")) {
try {
return createWinProcess(process).getPid();
}
catch (Error e) {
LOG.error("Failed to get PID with winp, fallback to default logic", e);
}
}
return WinProcessManager.getProcessId(process);
}
catch (Throwable e) {
throw new IllegalStateException("Cannot get PID from instance of " + process.getClass()
Expand Down

0 comments on commit 3db91ed

Please sign in to comment.