public interface ProcessTable
Modifier and Type | Interface and Description |
---|---|
static class |
ProcessTable.Factory
A factory for creating the process table instances.
|
Modifier and Type | Method and Description |
---|---|
java.util.stream.Stream<Integer> |
getAllPids()
Get all PIDs running on the system.
|
List<Integer> |
getJavaPid(java.util.stream.Stream<Integer> possiblePids,
Class<?> clazz)
Gets a Java PID running with the given class.
|
java.util.stream.Stream<Integer> |
getJavaPids()
Gets all the Java PIDs on the system that are readable by the current process.
|
boolean |
isProcessAlive(int pid) |
default boolean |
isProcessDead(int pid) |
default void |
stopProcess(int pid,
int timeoutMs)
Stops a process.
|
java.util.stream.Stream<Integer> getJavaPids() throws IOException
IOException
- if the /proc filesystem is not availablejava.util.stream.Stream<Integer> getAllPids() throws IOException
IOException
- if the program cannot read the process tableList<Integer> getJavaPid(@Nullable java.util.stream.Stream<Integer> possiblePids, Class<?> clazz) throws IOException
possiblePids
- a list of PIDs to check. If null, it will check all PIDs on the systemclazz
- the main class of the process that should be runningIOException
boolean isProcessAlive(int pid)
pid
- pid to testdefault boolean isProcessDead(int pid)
pid
- pid to testdefault void stopProcess(int pid, int timeoutMs) throws IOException, InterruptedException, TimeoutException
pid
- the PID to killtimeoutMs
- the total amount of time we should wait on the process dying before giving
upIOException
- If we can't read the process table or send a signalInterruptedException
- if we are interrupted waiting for the process to dieTimeoutException
- if we wait too long for the process to dieCopyright © 2023. All Rights Reserved.