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 List<String> |
execute(String[] cmdarray)
Executes the specified command and return the output.
|
static UnixProcessManager |
getDefault()
Gets the default instance of
UnixProcessManager. |
protected String[] |
getRunningProcessesCommand(String process)
Gets the command to be executed to get a snapshot of all the running processes identified by
the specified argument (process).
|
protected Pattern |
getRunningProcessLinePattern()
Gets the pattern to be used to match an output line containing the information about a running
process.
|
void |
kill(Process process,
long pid)
Kills the specified process.
|
void |
setRunAsArgs(String[] runAsArgs)
Sets The sudo command arguments.
|
findPidpublic static UnixProcessManager getDefault()
UnixProcessManager.UnixProcessManager instance.protected 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 String[] getRunningProcessesCommand(String process)
AbstractProcessManagergetRunningProcessesCommand in class AbstractProcessManagerprocess - The name of the process to query for.protected Pattern getRunningProcessLinePattern()
AbstractProcessManagergetRunningProcessLinePattern in class AbstractProcessManagerAbstractProcessManager.getRunningProcessesCommand(String)public void kill(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.