public class OSProcessHandler extends BaseOSProcessHandler
Modifier and Type | Class and Description |
---|---|
static class |
OSProcessHandler.Silent |
BaseOSProcessHandler.SimpleOutputReader
myCharset, myCommandLine, myPresentableName, myProcess, myWaitFor
SILENTLY_DESTROY_ON_CLOSE, TERMINATION_REQUESTED
Constructor and Description |
---|
OSProcessHandler(GeneralCommandLine commandLine) |
OSProcessHandler(java.lang.Process process)
Deprecated.
use
OSProcessHandler(Process, String) (or any other constructor) |
OSProcessHandler(java.lang.Process process,
java.lang.String commandLine)
commandLine must not be empty (for correct thread attribution in the stacktrace) |
OSProcessHandler(java.lang.Process process,
java.lang.String commandLine,
java.nio.charset.Charset charset)
commandLine must not be empty (for correct thread attribution in the stacktrace) |
OSProcessHandler(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 empty (for correct thread attribution in the stacktrace) |
Modifier and Type | Method and Description |
---|---|
static void |
checkEdtAndReadAction(ProcessHandler processHandler)
Checks if we are going to wait for
processHandler to finish on EDT or under ReadAction. |
static void |
deleteFileOnTermination(GeneralCommandLine commandLine,
java.io.File fileToDelete)
Registers a file to delete after the given command line finishes.
|
protected void |
doDestroyProcess() |
static ModalityState |
getDefaultModality() |
protected void |
killProcessTree(java.lang.Process process)
Kills the whole process tree asynchronously.
|
protected void |
onOSProcessTerminated(int exitCode) |
static boolean |
processCanBeKilledByOS(java.lang.Process process) |
protected boolean |
processHasSeparateErrorStream() |
protected BaseOutputReader.Options |
readerOptions()
Rule of thumb: use
BaseOutputReader.Options#BLOCKING for short-living process that you never want to "disconnect" from. |
void |
setHasPty(boolean hasPty)
In case of PTY this process handler will use blocking read because
InputStream.available() doesn't work for Pty4j, and there
is no reason to "disconnect" leaving PTY alive. |
void |
setShouldDestroyProcessRecursively(boolean destroyRecursively) |
protected boolean |
shouldDestroyProcessRecursively() |
boolean |
waitFor()
Wait for process execution.
|
boolean |
waitFor(long timeoutInMilliseconds) |
createErrorDataReader, createOutputDataReader, createProcessErrReader, createProcessOutReader, executeOnPooledThread, executeTask, startNotify, toString
closeStreams, destroyProcessImpl, detachIsDefault, detachProcessImpl, getCharset, getCommandLine, getProcess, getProcessInput
addProcessListener, addProcessListener, destroyProcess, detachProcess, getExitCode, isProcessTerminated, isProcessTerminating, isSilentlyDestroyOnClose, isStartNotified, notifyProcessDetached, notifyProcessTerminated, notifyTextAvailable, removeProcessListener
changeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
public OSProcessHandler(GeneralCommandLine commandLine) throws ExecutionException
ExecutionException
@Deprecated public OSProcessHandler(java.lang.Process process)
OSProcessHandler(Process, String)
(or any other constructor)public OSProcessHandler(java.lang.Process process, java.lang.String commandLine)
commandLine
must not be empty (for correct thread attribution in the stacktrace)public OSProcessHandler(java.lang.Process process, java.lang.String commandLine, java.nio.charset.Charset charset)
commandLine
must not be empty (for correct thread attribution in the stacktrace)public OSProcessHandler(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 empty (for correct thread attribution in the stacktrace)public static ModalityState getDefaultModality()
public boolean waitFor()
ProcessHandler
waitFor
in class BaseOSProcessHandler
public boolean waitFor(long timeoutInMilliseconds)
waitFor
in class BaseOSProcessHandler
public static void checkEdtAndReadAction(ProcessHandler processHandler)
processHandler
to finish on EDT or under ReadAction. Logs error if we do so.
ReadAction
:
other thread
and invoke a callback.Task.Backgroundable
WriteAction
:
modal progress
.Task.Backgroundable
WriteAction
other thread
and invoke a callback.Task.Backgroundable
protected void onOSProcessTerminated(int exitCode)
onOSProcessTerminated
in class BaseProcessHandler<java.lang.Process>
protected boolean processHasSeparateErrorStream()
processHasSeparateErrorStream
in class BaseOSProcessHandler
protected boolean shouldDestroyProcessRecursively()
public void setShouldDestroyProcessRecursively(boolean destroyRecursively)
protected void doDestroyProcess()
doDestroyProcess
in class BaseProcessHandler<java.lang.Process>
public static boolean processCanBeKilledByOS(java.lang.Process process)
protected void killProcessTree(java.lang.Process process)
process
- Processpublic void setHasPty(boolean hasPty)
In case of PTY this process handler will use blocking read because InputStream.available()
doesn't work for Pty4j, and there
is no reason to "disconnect" leaving PTY alive. See BaseDataReader.SleepingPolicy
for more info.
The value should be set before BaseOSProcessHandler.startNotify()
invocation.
It is set by default in case of using GeneralCommandLine based constructor.
hasPty
- true
if process is PTY-based.protected BaseOutputReader.Options readerOptions()
BaseOutputReader.Options#BLOCKING
for short-living process that you never want to "disconnect" from.
See BaseDataReader.SleepingPolicy
for the whole story.readerOptions
in class BaseOSProcessHandler
public static void deleteFileOnTermination(GeneralCommandLine commandLine, java.io.File fileToDelete)
OSProcessHandler(GeneralCommandLine)
.