public final class ProcessCommands


Commands about processes.

Summary

Public methods

final int
getPid(@NonNull String processName)

Gets the pid of a given process name.

final boolean
isProcessAlive(int pid)

Returns whether the given process id is associated with a process that is alive.

final void
killPid(int pid, @NonNull String signal)

Kills a process with the given pid using the given signal.

final @NonNull List<@NonNull ProcessPid>
processGrep(@NonNull String processName)

Runs process grep (pgrep) with the given process name.

Public methods

getPid

Added in 1.0.0-alpha01
public final int getPid(@NonNull String processName)

Gets the pid of a given process name. Note that underlying this api utilizes pgrep and returns the pid associated to the first process with the name starting with the given processName, or -1 if not found.

Parameters
@NonNull String processName

the name of the process to get the pid of.

Returns
int

the pid of the process if found or -1.

isProcessAlive

Added in 1.0.0-alpha01
public final boolean isProcessAlive(int pid)

Returns whether the given process id is associated with a process that is alive.

killPid

Added in 1.0.0-alpha01
public final void killPid(int pid, @NonNull String signal)

Kills a process with the given pid using the given signal.

Parameters
int pid

the pid of the process to kill.

@NonNull String signal

the name of the signal to send to the process.

processGrep

Added in 1.0.0-alpha01
public final @NonNull List<@NonNull ProcessPidprocessGrep(@NonNull String processName)

Runs process grep (pgrep) with the given process name.

Parameters
@NonNull String processName

the name of the process to grep for.

Returns
@NonNull List<@NonNull ProcessPid>

a list of ProcessPid containing the pid and process name for each matching grep.