Interface IAsynchronousProcess
-
- All Superinterfaces:
IProcess
- All Known Implementing Classes:
AsynchronousProcess
public interface IAsynchronousProcess extends IProcess
Defines an asynchronous process
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Close and cleanup the process.voiddestroy()Destroy the process immediate.java.io.OutputStreamgetInputStream()Returns the output stream connected to the process input stream.java.lang.ProcessHandlegetProcessHandle()Get the process handle.booleanisAlive()Check whether the process is alive.voidtryDestroy()Try to kill the process.intwaitFor()Wait, if necessary, until the process is terminated.booleanwaitFor(long timeout, java.util.concurrent.TimeUnit unit)Wait, if necessary, until the process is terminated.-
Methods inherited from interface com.github.toolarium.system.command.process.IProcess
getExitValue, getPid, getStartTime, getSystemCommandGroupList, getTotalCpuDuration
-
-
-
-
Method Detail
-
waitFor
int waitFor() throws java.lang.InterruptedExceptionWait, if necessary, until the process is terminated. This method returns immediately if the process has already terminated. If the process has not yet terminated, the calling thread will be blocked until the process exits.- Returns:
- the exit value, by convention, the value
0indicates normal termination - Throws:
java.lang.InterruptedException- if the current thread is interrupted by another thread while it is waiting, then the wait is ended and anInterruptedExceptionis thrown.
-
waitFor
boolean waitFor(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionWait, if necessary, until the process is terminated. This method returns immediately if the process has already terminated or the specified waiting time elapses.The default implementation of this methods polls the
exitValueto check if the process has terminated. Concrete implementations of this class are strongly encouraged to override this method with a more efficient implementation.- Parameters:
timeout- the maximum time to waitunit- the time unit of thetimeoutargument- Returns:
- true if the process has exited; othweise false if the waiting time elapsed before the process has exited
- Throws:
java.lang.InterruptedException- if the current thread is interrupted while waiting.
-
isAlive
boolean isAlive()
Check whether the process is alive.- Returns:
- true if it is alive; othweise false
-
tryDestroy
void tryDestroy()
Try to kill the process.
-
destroy
void destroy()
Destroy the process immediate. If the process is not alive, no action is taken.
-
getInputStream
java.io.OutputStream getInputStream()
Returns the output stream connected to the process input stream. If the standard input of the process has been redirected, the stream is not available.- Returns:
- the input stream
-
getProcessHandle
java.lang.ProcessHandle getProcessHandle()
Get the process handle.- Returns:
- the process handle
-
close
void close()
Close and cleanup the process. If the process is not finalised the close wait until the process is finished.
-
-