Module process
Processes, signals, and signal handlers.
Functions
pid () | Returns the PID of the current process. |
pidof (process) | Returns the PID (process ID) of the given process, or nil if the process could not be found. |
signum (signal) | Returns the given signal as an integer. |
send (pid, signal) | Sends the given signal to the process with the given PID. |
kill (pid) | Kills the process with the given PID. |
terminate (pid) | Terminates the process with the given PID. |
Functions
- pid ()
-
Returns the PID of the current process.
Usage:
local pid = process.pid()
- pidof (process)
-
Returns the PID (process ID) of the given process,
or nil if the process could not be found.
Depends on the nonportable userspace utility
pgrep
. Can be found in the procps-ng package on Linux usually included in most distributions, or as part of the base system on OpenBSD, NetBSD and FreeBSD.Parameters:
- process string The name of the process to look up.
Usage:
process.pidof("init")
- signum (signal)
-
Returns the given signal as an integer.
This signal value is a platform-dependent value; do not attempt to use it portably across different platforms.
Parameters:
- signal string The signal to look up.
Usage:
local sigkill = process.signum("SIGKILL")
- send (pid, signal)
-
Sends the given signal to the process with the given PID.
The signal parameter is a string containing the name of the desired signal to send (e.g. SIGKILL).
Parameters:
- pid integer The PID of the process.
- signal string The signal to send.
Usage:
local pid = process.pid("sh") process.send(pid, "SIGTERM")
- kill (pid)
-
Kills the process with the given PID.
Equivalent to
process.send(pid, "SIGKILL")
.Parameters:
- pid integer The PID of the process.
- terminate (pid)
-
Terminates the process with the given PID.
Equivalent to
process.send(pid, "SIGTERM")
.Parameters:
- pid integer The PID of the process.