Package org.zeroturnaround.exec
Class WaitForProcess
java.lang.Object
org.zeroturnaround.exec.WaitForProcess
- All Implemented Interfaces:
Callable<ProcessResult>
Handles the executed process.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ProcessAttributes
Set of main attributes used to start the process.private final ProcessCloser
Helper for closing the process' standard streams.private final ProcessListener
Process event listener (notnull
).private static final org.slf4j.Logger
private final MessageLogger
Helper for logging messages about starting and waiting for the processes.private final ByteArrayOutputStream
Buffer where the process output is redirected to ornull
if it's not used.private final Process
private final ProcessStopper
Helper for stopping the process in case of interruption.private Thread
Thread 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 TypeMethodDescriptionvoid
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)call()
private ProcessOutput
toString()
-
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 ornull
if 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:
call
in interfaceCallable<ProcessResult>
- Throws:
IOException
InterruptedException
-
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,
null
if this operation is currently not running.
-
toString
-