Package io.quarkus.deployment.util
Class ProcessUtil
java.lang.Object
io.quarkus.deployment.util.ProcessUtil
Utility for
Process
related operations-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Process
launchProcess
(ProcessBuilder builder, boolean shouldRedirectIO) static Process
launchProcessStreamStdOut
(ProcessBuilder builder, boolean shouldRedirectIO) static void
streamErrorTo
(PrintStream printStream, Process process) static void
streamErrorToSysErr
(Process process) static void
streamOutputToSysOut
(Process process) static void
streamToSysOutSysErr
(Process process) This is a convenience method which internally calls both thestreamOutputToSysOut(Process)
andstreamErrorToSysErr(Process)
methods
-
Constructor Details
-
ProcessUtil
public ProcessUtil()
-
-
Method Details
-
launchProcess
public static Process launchProcess(ProcessBuilder builder, boolean shouldRedirectIO) throws IOException Launches and returns aProcess
built from thebuilder
. Before launching the process, this method checks if inherit IO is disabled and if so, streams both theSTDOUT
andSTDERR
of the launched process usingstreamToSysOutSysErr(Process)
. Else, it launches the process withProcessBuilder.inheritIO()
- Parameters:
builder
- The process buildershouldRedirectIO
- WhetherProcessBuilder.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 aProcess
built from thebuilder
. Before launching the process, this method checks if inheritIO is disabled and if so, streams (only) theSTDOUT
of the launched process usingstreamOutputToSysOut(Process)
(Process)}. Else, it launches the process withProcessBuilder.inheritIO()
- Parameters:
builder
- The process buildershouldRedirectIO
- WhetherProcessBuilder.Redirect.INHERIT
can be used for launching the process- Returns:
- Returns the newly launched process
- Throws:
IOException
-
streamToSysOutSysErr
This is a convenience method which internally calls both thestreamOutputToSysOut(Process)
andstreamErrorToSysErr(Process)
methods- Parameters:
process
- The process whose STDOUT and STDERR needs to be streamed.
-
streamOutputToSysOut
Streams theprocess'
STDOUT
to the current process'System.out stream
. This creates and starts a thread to stream the contents. TheProcess
is expected to have been started inProcessBuilder.Redirect.PIPE
mode- Parameters:
process
- The process whose STDOUT needs to be streamed.
-
streamErrorToSysErr
Streams theprocess'
STDERR
to the current process'System.err stream
. This creates and starts a thread to stream the contents. TheProcess
is expected to have been started inProcessBuilder.Redirect.PIPE
mode- Parameters:
process
- The process whose STDERR needs to be streamed.
-
streamErrorTo
Streams theprocess'
STDERR
to the givenprintStream
. This creates and starts a thread to stream the contents. TheProcess
is expected to have been started inProcessBuilder.Redirect.PIPE
mode- Parameters:
process
- The process whose STDERR needs to be streamed.
-