Class WaitForProcess
java.lang.Object
org.zeroturnaround.exec.WaitForProcess
- All Implemented Interfaces:
Callable<ProcessResult>
Handles the executed process.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ProcessAttributesSet of main attributes used to start the process.private final ProcessCloserHelper for closing the process' standard streams.private final ProcessListenerProcess event listener (notnull).private static final org.slf4j.Loggerprivate final MessageLoggerHelper for logging messages about starting and waiting for the processes.private final ByteArrayOutputStreamBuffer where the process output is redirected to ornullif it's not used.private final Processprivate final ProcessStopperHelper for stopping the process in case of interruption.private ThreadThread which executes this operation. -
Constructor Summary
ConstructorsConstructorDescriptionWaitForProcess(Process process, ProcessAttributes attributes, ProcessStopper stopper, ProcessCloser closer, ByteArrayOutputStream out, ProcessListener listener, MessageLogger messageLogger) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a suffix for an error message including: executed command working directory (unless it's inherited from parent) environment (unless it's the same with the parent) output read so far (unless it's not read)call()private ProcessOutputtoString()
-
Field Details
-
log
private static final org.slf4j.Logger log -
process
-
attributes
Set of main attributes used to start the process. -
stopper
Helper for stopping the process in case of interruption. -
closer
Helper for closing the process' standard streams. -
out
Buffer where the process output is redirected to ornullif it's not used. -
listener
Process event listener (notnull). -
messageLogger
Helper for logging messages about starting and waiting for the processes. -
workerThread
Thread which executes this operation.
-
-
Constructor Details
-
WaitForProcess
public WaitForProcess(Process process, ProcessAttributes attributes, ProcessStopper stopper, ProcessCloser closer, ByteArrayOutputStream out, ProcessListener listener, MessageLogger messageLogger)
-
-
Method Details
-
getProcess
- Returns:
- the sub process.
-
call
- Specified by:
callin interfaceCallable<ProcessResult>- Throws:
IOExceptionInterruptedException
-
getCurrentOutput
-
addExceptionMessageSuffix
Adds a suffix for an error message including:- executed command
- working directory (unless it's inherited from parent)
- environment (unless it's the same with the parent)
- output read so far (unless it's not read)
- Parameters:
sb- where the suffix is appended to.
-
getStackTrace
- Returns:
- current stacktrace of the worker thread,
nullif this operation is currently not running.
-
toString
-