public class KillableProcessHandler extends OSProcessHandler implements KillableProcess
KillableProcessHandler).
At first "stop" button send SIGINT signal to process, if it still hangs user can terminate it recursively with SIGKILL signal.
Soft kill works on Unix, and also on Windows if a mediator process was used.
OSProcessHandler.SilentBaseOSProcessHandler.SimpleOutputReadermyCharset, myCommandLine, myPresentableName, myProcess, myWaitForSILENTLY_DESTROY_ON_CLOSE, TERMINATION_REQUESTED| Constructor and Description |
|---|
KillableProcessHandler(GeneralCommandLine commandLine) |
KillableProcessHandler(GeneralCommandLine commandLine,
boolean withMediator)
|
KillableProcessHandler(java.lang.Process process,
java.lang.String commandLine)
commandLine must not be not empty (for correct thread attribution in the stacktrace) |
KillableProcessHandler(java.lang.Process process,
java.lang.String commandLine,
java.nio.charset.Charset charset)
commandLine must not be not empty (for correct thread attribution in the stacktrace) |
KillableProcessHandler(java.lang.Process process,
java.lang.String commandLine,
java.nio.charset.Charset charset,
java.util.Set<? extends java.io.File> filesToDelete)
commandLine must not be not empty (for correct thread attribution in the stacktrace) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canKillProcess() |
protected boolean |
destroyProcessGracefully() |
protected void |
destroyProcessImpl()
Performs process destruction.
|
protected void |
doDestroyProcess() |
void |
killProcess() |
protected static GeneralCommandLine |
mediate(GeneralCommandLine commandLine,
boolean withMediator,
boolean showConsole) |
protected void |
notifyProcessTerminated(int exitCode) |
void |
setShouldKillProcessSoftly(boolean shouldKillProcessSoftly)
Sets whether the process will be terminated gracefully.
|
void |
setShouldKillProcessSoftlyWithWinP(boolean shouldKillProcessSoftlyWithWinP)
Enables sending Ctrl+C to a Windows-process on first termination attempt.
|
boolean |
shouldKillProcessSoftly() |
checkEdtAndReadAction, deleteFileOnTermination, getDefaultModality, killProcessTree, onOSProcessTerminated, processCanBeKilledByOS, processHasSeparateErrorStream, readerOptions, setHasPty, setShouldDestroyProcessRecursively, shouldDestroyProcessRecursively, waitFor, waitForcreateErrorDataReader, createOutputDataReader, createProcessErrReader, createProcessOutReader, executeOnPooledThread, executeTask, startNotify, toStringcloseStreams, detachIsDefault, detachProcessImpl, getCharset, getCommandLine, getProcess, getProcessInputaddProcessListener, addProcessListener, destroyProcess, detachProcess, getExitCode, isProcessTerminated, isProcessTerminating, isSilentlyDestroyOnClose, isStartNotified, notifyProcessDetached, notifyTextAvailable, removeProcessListenerchangeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMappublic KillableProcessHandler(GeneralCommandLine commandLine) throws ExecutionException
ExecutionExceptionpublic KillableProcessHandler(GeneralCommandLine commandLine, boolean withMediator) throws ExecutionException
ExecutionExceptionpublic KillableProcessHandler(java.lang.Process process,
java.lang.String commandLine)
commandLine must not be not empty (for correct thread attribution in the stacktrace)public KillableProcessHandler(java.lang.Process process,
java.lang.String commandLine,
java.nio.charset.Charset charset)
commandLine must not be not empty (for correct thread attribution in the stacktrace)public KillableProcessHandler(java.lang.Process process,
java.lang.String commandLine,
java.nio.charset.Charset charset,
java.util.Set<? extends java.io.File> filesToDelete)
commandLine must not be not empty (for correct thread attribution in the stacktrace)protected static GeneralCommandLine mediate(GeneralCommandLine commandLine, boolean withMediator, boolean showConsole)
public boolean shouldKillProcessSoftly()
public void setShouldKillProcessSoftly(boolean shouldKillProcessSoftly)
shouldKillProcessSoftly - true, if graceful process termination should be attempted first (i.e. soft kill)protected void destroyProcessImpl()
ProcessHandlerThis is an internal implementation of ProcessHandler.destroyProcess(). All sub-classes must implement this method and perform the
destruction in this method. This method is called from ProcessHandler.destroyProcess() and it can be in any thread including the
event dispatcher thread. You should avoid doing any expensive operation directly in this method. Instead, you may post the work to
background thread and return without waiting for it. If the performed destruction led to process termination,
ProcessHandler.notifyProcessTerminated(int) must be called in any thread (not necessary from this method).
destroyProcessImpl in class BaseProcessHandler<java.lang.Process>protected void notifyProcessTerminated(int exitCode)
notifyProcessTerminated in class ProcessHandlerprotected void doDestroyProcess()
doDestroyProcess in class OSProcessHandlerpublic void setShouldKillProcessSoftlyWithWinP(boolean shouldKillProcessSoftlyWithWinP)
shouldKillProcessSoftlyWithWinP - true to useprotected boolean destroyProcessGracefully()
public boolean canKillProcess()
canKillProcess in interface KillableProcesspublic void killProcess()
killProcess in interface KillableProcess