class ProcessCommands


Commands about processes.

Summary

Public functions

Int
getPid(processName: String)

Gets the pid of a given process name.

Boolean

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

Unit
killPid(pid: Int, signal: String)

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

Added in 1.0.0-alpha01
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 starting 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

Added in 1.0.0-alpha01
fun isProcessAlive(pid: Int): Boolean

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

killPid

Added in 1.0.0-alpha01
fun killPid(pid: Int, signal: String = "TERM"): Unit

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

Parameters
pid: Int

the pid of the process to kill.

signal: String = "TERM"

the name of the signal to send to the process.

processGrep

Added in 1.0.0-alpha01
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 ProcessPid containing the pid and process name for each matching grep.