mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-156065 WinPty process does not kill agent on end - fixed incorrect exit code after winptyprocess termination
This commit is contained in:
+11
-3
@@ -67,7 +67,7 @@ public class CapturingProcessHandler extends OSProcessHandler {
|
||||
public ProcessOutput runProcess() {
|
||||
startNotify();
|
||||
if (waitFor()) {
|
||||
myOutput.setExitCode(getProcess().exitValue());
|
||||
setErrorCodeIfNotYetSet();
|
||||
}
|
||||
else {
|
||||
LOG.info("runProcess: exit value unavailable");
|
||||
@@ -75,6 +75,14 @@ public class CapturingProcessHandler extends OSProcessHandler {
|
||||
return myOutput;
|
||||
}
|
||||
|
||||
private void setErrorCodeIfNotYetSet() {
|
||||
// if exit code was set on processTerminated, no need to rewrite it
|
||||
// WinPtyProcess returns -2 if pty is already closed
|
||||
if (myOutput.hasErrorExitCode()) {
|
||||
myOutput.setExitCode(getProcess().exitValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts process with specified timeout
|
||||
*
|
||||
@@ -97,7 +105,7 @@ public class CapturingProcessHandler extends OSProcessHandler {
|
||||
else {
|
||||
startNotify();
|
||||
if (waitFor(timeoutInMilliseconds)) {
|
||||
myOutput.setExitCode(getProcess().exitValue());
|
||||
setErrorCodeIfNotYetSet();
|
||||
}
|
||||
else {
|
||||
if (destroyOnTimeout) {
|
||||
@@ -156,7 +164,7 @@ public class CapturingProcessHandler extends OSProcessHandler {
|
||||
}
|
||||
if (setExitCode) {
|
||||
if (waitFor()) {
|
||||
myOutput.setExitCode(getProcess().exitValue());
|
||||
setErrorCodeIfNotYetSet();
|
||||
}
|
||||
else {
|
||||
LOG.info("runProcess: exit value unavailable");
|
||||
|
||||
Reference in New Issue
Block a user