Class ProcessUtil

java.lang.Object
io.quarkus.deployment.util.ProcessUtil

public class ProcessUtil extends Object
Utility for Process related operations
  • Constructor Details

    • ProcessUtil

      public ProcessUtil()
  • Method Details

    • launchProcess

      public static Process launchProcess(ProcessBuilder builder, boolean shouldRedirectIO) throws IOException
      Launches and returns a Process built from the builder. Before launching the process, this method checks if inherit IO is disabled and if so, streams both the STDOUT and STDERR of the launched process using streamToSysOutSysErr(Process). Else, it launches the process with ProcessBuilder.inheritIO()
      Parameters:
      builder - The process builder
      shouldRedirectIO - Whether ProcessBuilder.Redirect.INHERIT can be used for launching the process
      Returns:
      Returns the newly launched process
      Throws:
      IOException
    • launchProcessStreamStdOut

      public static Process launchProcessStreamStdOut(ProcessBuilder builder, boolean shouldRedirectIO) throws IOException
      Launches and returns a Process built from the builder. Before launching the process, this method checks if inheritIO is disabled and if so, streams (only) the STDOUT of the launched process using streamOutputToSysOut(Process) (Process)}. Else, it launches the process with ProcessBuilder.inheritIO()
      Parameters:
      builder - The process builder
      shouldRedirectIO - Whether ProcessBuilder.Redirect.INHERIT can be used for launching the process
      Returns:
      Returns the newly launched process
      Throws:
      IOException
    • streamToSysOutSysErr

      public static void streamToSysOutSysErr(Process process)
      This is a convenience method which internally calls both the streamOutputToSysOut(Process) and streamErrorToSysErr(Process) methods
      Parameters:
      process - The process whose STDOUT and STDERR needs to be streamed.
    • streamOutputToSysOut

      public static void streamOutputToSysOut(Process process)
      Streams the process' STDOUT to the current process' System.out stream. This creates and starts a thread to stream the contents. The Process is expected to have been started in ProcessBuilder.Redirect.PIPE mode
      Parameters:
      process - The process whose STDOUT needs to be streamed.
    • streamErrorToSysErr

      public static void streamErrorToSysErr(Process process)
      Streams the process' STDERR to the current process' System.err stream. This creates and starts a thread to stream the contents. The Process is expected to have been started in ProcessBuilder.Redirect.PIPE mode
      Parameters:
      process - The process whose STDERR needs to be streamed.
    • streamErrorTo

      public static void streamErrorTo(PrintStream printStream, Process process)
      Streams the process' STDERR to the given printStream. This creates and starts a thread to stream the contents. The Process is expected to have been started in ProcessBuilder.Redirect.PIPE mode
      Parameters:
      process - The process whose STDERR needs to be streamed.