Skip to content

Commit

Permalink
fix: stop the debug process gracefully
Browse files Browse the repository at this point in the history
Fix #75
  • Loading branch information
yuezk committed Jul 1, 2023
1 parent 5cab23e commit 8005382
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import com.intellij.execution.configurations.JavaCommandLineState;
import com.intellij.execution.configurations.JavaParameters;
import com.intellij.execution.configurations.ParametersList;
import com.intellij.execution.process.KillableProcessHandler;
import com.intellij.execution.process.KillableColoredProcessHandler;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.process.ProcessTerminatedListener;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.openapi.module.Module;
Expand Down Expand Up @@ -92,12 +93,13 @@ protected GeneralCommandLine createCommandLine() throws ExecutionException {
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
OSProcessHandler progressHandler = super.startProcess();
if (progressHandler instanceof KillableProcessHandler) {
boolean shouldKillSoftly = !DebuggerSettings.getInstance().KILL_PROCESS_IMMEDIATELY;
((KillableProcessHandler) progressHandler).setShouldKillProcessSoftly(shouldKillSoftly);
}
return progressHandler;
KillableColoredProcessHandler processHandler = new KillableColoredProcessHandler(createCommandLine());
boolean shouldKillSoftly = !DebuggerSettings.getInstance().KILL_PROCESS_IMMEDIATELY;

processHandler.setShouldKillProcessSoftly(shouldKillSoftly);
ProcessTerminatedListener.attach(processHandler);

return processHandler;
}

@Override
Expand Down

0 comments on commit 8005382

Please sign in to comment.