Class ProcessHandle
java.lang.Object
org.opentestfactory.utils.process.ProcessHandle
This class is a process handle. It allows process streams monitoring and process termination
management.
- Author:
- edegenetais
-
Constructor Summary
ConstructorsConstructorDescriptionProcessHandle(Process process) Create a process handle without shutdown hook.ProcessHandle(String processName, Process process, boolean registerShutdownHook, boolean monitorErrorStream) Create a process handle.ProcessHandle(String processName, Process process, boolean registerShutdownHook, boolean monitorStdoutStream, boolean monitorErrorStream, int maxLength) ProcessHandle(String processName, Process process, boolean registerShutdownHook, boolean monitorErrorStream, int maxLength) Create a process handle. -
Method Summary
Modifier and TypeMethodDescriptionGet the last 200 lines of the process error stream.Get the last 200 lines of the process error stream.booleanCheck if the underlying process is still alive.voidKill the underlying process.
-
Constructor Details
-
ProcessHandle
Create a process handle without shutdown hook.- Parameters:
process- process to manage.
-
ProcessHandle
public ProcessHandle(String processName, Process process, boolean registerShutdownHook, boolean monitorErrorStream) Create a process handle.- Parameters:
processName- name for the processprocess- process to manage.registerShutdownHook- whether to register a process shutdown hook or not.monitorErrorStream- if the error stream should be monitored.
-
ProcessHandle
public ProcessHandle(String processName, Process process, boolean registerShutdownHook, boolean monitorErrorStream, int maxLength) Create a process handle.- Parameters:
processName- name for the processprocess- process to manage.registerShutdownHook- whether to register a process shutdown hook or not.monitorErrorStream- if the error stream should be monitored.maxLength- max stderr record length to keep
-
ProcessHandle
-
-
Method Details
-
killProcess
public void killProcess()Kill the underlying process. -
isProcessAlive
public boolean isProcessAlive()Check if the underlying process is still alive.- Returns:
trueif alive,falseif dead.
-
returnValue
- Returns:
- process's return value.
-
getErrorStream
Get the last 200 lines of the process error stream.- Returns:
-
getStdoutStream
Get the last 200 lines of the process error stream.- Returns:
-
getProcessName
-