public final class OperatingSystem extends Object
Modifier and Type | Field and Description |
---|---|
static long |
MAX_NR_OPENFILES |
Modifier and Type | Method and Description |
---|---|
static String |
forkExec(String[] command,
long timeoutMillis) |
static <T,E> ProcessResponse<T,E> |
forkExec(String[] command,
ProcessHandler<T,E> handler,
long timeoutMillis,
long terminationTimeoutMillis)
Process execution utility.
|
static void |
forkExecLog(String[] command,
long timeoutMillis) |
static long |
getMaxFileDescriptorCount() |
static long |
getOpenFileDescriptorCount() |
static OperatingSystemMXBean |
getOSMbean() |
static com.sun.management.OperatingSystemMXBean |
getSunJdkOSMBean() |
static com.sun.management.UnixOperatingSystemMXBean |
getUnixOsMBean() |
static int |
killProcess(Process proc,
long terminateTimeoutMillis,
long forceTerminateTimeoutMillis) |
public static OperatingSystemMXBean getOSMbean()
@Nullable public static com.sun.management.OperatingSystemMXBean getSunJdkOSMBean()
@Nullable public static com.sun.management.UnixOperatingSystemMXBean getUnixOsMBean()
public static long getOpenFileDescriptorCount()
public static long getMaxFileDescriptorCount()
public static int killProcess(Process proc, long terminateTimeoutMillis, long forceTerminateTimeoutMillis) throws InterruptedException, TimeoutException
InterruptedException
TimeoutException
public static <T,E> ProcessResponse<T,E> forkExec(String[] command, ProcessHandler<T,E> handler, long timeoutMillis, long terminationTimeoutMillis) throws IOException, InterruptedException, ExecutionException, TimeoutException
T
- type the stdout is reduced to.E
- type stderr is reduced to.command
- the command to execute.handler
- handler for child stdin, stdout and stderr. stdout and stderr handling will be done in 2 threads
from the DefaultExecutor thread pool. while stdin handling will execute in the current thread.timeoutMillis
- time to wait for the process to execute.terminationTimeoutMillis
- this is the timeout used when trying to terminate the process gracefully.IOException
InterruptedException
ExecutionException
TimeoutException
- when timeout happens.@CheckReturnValue public static String forkExec(String[] command, long timeoutMillis) throws IOException, InterruptedException, ExecutionException, TimeoutException
public static void forkExecLog(String[] command, long timeoutMillis) throws IOException, InterruptedException, ExecutionException, TimeoutException
Copyright © 2018 SPF4J. All rights reserved.