public class UnixProcessManager extends AbstractProcessManager
ProcessManager implementation for *nix systems. Uses the
ps and kill commands.
Works for Linux. Works for Solaris too, except that the command line string returned by ps there is limited to 80 characters and this affects AbstractProcessManager.findPid(ProcessQuery).
PID_NOT_FOUND, PID_UNKNOWN| Constructor and Description |
|---|
UnixProcessManager() |
| Modifier and Type | Method and Description |
|---|---|
protected @NonNull List<String> |
execute(String... cmdarray)
Executes the specified command and return the output.
|
static @NonNull UnixProcessManager |
getDefault()
Gets the default instance of
UnixProcessManager. |
protected @NonNull String[] |
getRunningProcessesCommand(@NonNull String process)
Gets the command to be executed to get a snapshot of all the running processes identified by
the specified argument (process).
|
protected @NonNull Pattern |
getRunningProcessLinePattern()
Gets the pattern to be used to match an output line containing the information about a running
process.
|
void |
kill(@Nullable Process process,
long pid)
Kills the specified process.
|
void |
setRunAsArgs(String... runAsArgs)
Sets The sudo command arguments.
|
findPidclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanFindPidpublic static @NonNull UnixProcessManager getDefault()
UnixProcessManager.UnixProcessManager instance.protected @NonNull List<String> execute(String... cmdarray) throws IOException
AbstractProcessManagerexecute in class AbstractProcessManagercmdarray - An array containing the command to call and its arguments.IOException - If an I/O error occurs.protected @NonNull String[] getRunningProcessesCommand(@NonNull String process)
AbstractProcessManagergetRunningProcessesCommand in class AbstractProcessManagerprocess - The name of the process to query for.protected @NonNull Pattern getRunningProcessLinePattern()
AbstractProcessManagergetRunningProcessLinePattern in class AbstractProcessManagerAbstractProcessManager.getRunningProcessesCommand(String)public void kill(@Nullable Process process, long pid) throws IOException
ProcessManagerprocess - The process to kill.pid - The id of the process to kill.IOException - If an IO error occurs.public void setRunAsArgs(String... runAsArgs)
runAsArgs - The sudo command arguments.Copyright © 2016 - present; JODConverter.org. All rights reserved.