Module posix.signal
Software Signal Facilities.
Constants and functions for propagating signals among processes.
Note that posix.signal.signal
is implemented with sigaction(2) for
consistent semantics across platforms.
Functions
kill (pid, opt) | Send a signal to the given process. |
killpg (pgrp[, sig=`SIGTERM`]) | Send a signal to the given process group. |
raise (sig) | Raise a signal on this process. |
signal (signum[, handler=SIG_DFL[, flags]]) | Install a signal handler for this signal number. |
Constants
posix.signal | Signal constants. |
Functions
- kill (pid, opt)
-
Send a signal to the given process.
Parameters:
- pid int process to act on
- opt
int
=
SIGTERM
sig signal to send
Returns:
-
int
0
, if successfulOr
- nil
- string error message
- int errnum
See also:
- killpg (pgrp[, sig=`SIGTERM`])
-
Send a signal to the given process group.
Parameters:
- pgrp
int
group id to act on, or
0
for the sending process`s group - sig int signal to send (default `SIGTERM`)
Returns:
-
int
0
, if successfulOr
- nil
- string error message
- int errnum
See also:
- pgrp
int
group id to act on, or
- raise (sig)
-
Raise a signal on this process.
Parameters:
- sig int signal to send
Returns:
-
int
0
, if successfulOr
- nil
- string error message
- int errnum
See also:
- signal (signum[, handler=SIG_DFL[, flags]])
-
Install a signal handler for this signal number.
Although this is the same API as signal(2), it uses sigaction for guaranteed semantics.
Parameters:
- signum int
- handler
function
function, or
SIG_IGN
orSIG_DFL
constants (default SIG_DFL) - flags
the
sa_flags
element ofstruct sigaction
(optional)
Returns:
-
function
previous handler function
See also:
Constants
- posix.signal
-
Signal constants.
Any constants not available in the underlying system will be
nil
valued.Fields:
- SIGABRT int abort ()
- SIGALRM int alarm clock
- SIGBUS int bus error
- SIGCHLD int to parent on child stop or exit
- SIGCONT int continue a stopped process
- SIGFPE int floating point error
- SIGHUP int hangup
- SIGILL int illegal instruction
- SIGINT int interrupt
- SIGKILL int kill
- SIGPIPE int write on pipe with no reader
- SIGQUIT int quit
- SIGSEGV int segmentation violation
- SIGSTOP int stop
- SIGTERM int terminate
- SIGTSTP int stop signal from tty
- SIGTTIN int to readers process group on background tty read
- SIGTTOU int to readers process group on background tty output
- SIGUSR1 int user defined
- SIGUSR2 int user defined
- SIGSYS int bad argument to system call
- SIGTRAP int trace trap
- SIGURG int urgent condition on i/o channel
- SIGVTALRM int virtual time alarm
- SIGXCPU int exceeded cpu time limit
- SIGXFSZ int exceeded file size limit
- SA_NOCLDSTOP int do not generate a SIGCHLD on child stop
- SA_NOCLDWAIT int don't keep zombies child processes
- SA_RESETHAND int reset to SIG_DFL when taking a signal
- SA_NODEFER int don't mask the signal we're delivering
Usage:
-- Print signal constants supported on this host. for name, value in pairs (require "posix.signal") do if type (value) == "number" then print (name, value) end end