ProcessCommands
class ProcessCommands
Commands about processes.
Summary
Public functions |
|
---|---|
Int |
Gets the pid of a given process name. |
Boolean |
isProcessAlive(pid: Int) Returns whether the given process id is associated with a process that is alive. |
Unit |
Kills a process with the given pid using the given signal. |
List<ProcessPid> |
processGrep(processName: String) Runs process grep (pgrep) with the given process name. |
Public functions
getPid
fun getPid(processName: String): Int
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 matching with the given processName
, or -1 if not found.
Parameters | |
---|---|
processName: String |
the name of the process to get the pid of. |
Returns | |
---|---|
Int |
the pid of the process if found or -1. |
isProcessAlive
fun isProcessAlive(pid: Int): Boolean
Returns whether the given process id is associated with a process that is alive.
killPid
fun killPid(pid: Int, signal: String = "TERM"): Unit
Kills a process with the given pid using the given signal.
processGrep
fun processGrep(processName: String): List<ProcessPid>
Runs process grep (pgrep) with the given process name.
Parameters | |
---|---|
processName: String |
the name of the process to grep for. |
Returns | |
---|---|
List<ProcessPid> |
a list of |