Class WaitForProcess

java.lang.Object
org.zeroturnaround.exec.WaitForProcess
All Implemented Interfaces:
Callable<ProcessResult>

class WaitForProcess extends Object implements Callable<ProcessResult>
Handles the executed process.
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • process

      private final Process process
    • attributes

      private final ProcessAttributes attributes
      Set of main attributes used to start the process.
    • stopper

      private final ProcessStopper stopper
      Helper for stopping the process in case of interruption.
    • closer

      private final ProcessCloser closer
      Helper for closing the process' standard streams.
    • out

      private final ByteArrayOutputStream out
      Buffer where the process output is redirected to or null if it's not used.
    • listener

      private final ProcessListener listener
      Process event listener (not null).
    • messageLogger

      private final MessageLogger messageLogger
      Helper for logging messages about starting and waiting for the processes.
    • workerThread

      private volatile Thread workerThread
      Thread which executes this operation.
  • Constructor Details

  • Method Details

    • getProcess

      public Process getProcess()
      Returns:
      the sub process.
    • call

      Specified by:
      call in interface Callable<ProcessResult>
      Throws:
      IOException
      InterruptedException
    • getCurrentOutput

      private ProcessOutput getCurrentOutput()
    • addExceptionMessageSuffix

      public void addExceptionMessageSuffix(StringBuilder sb)
      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

      public StackTraceElement[] getStackTrace()
      Returns:
      current stacktrace of the worker thread, null if this operation is currently not running.
    • toString

      public String toString()
      Overrides:
      toString in class Object