SPVM::Sys::Signal - Signal System Call
use Sys::Signal; use Sys::Signal::Constant as SIGNAL; Sys::Signal->raise(SIGNAL->SIGTERM); Sys::Signal->kill($process_id, SIGNAL->SIGINT); Sys::Signal->signal(SIGNAL->SIGTERM, Sys::Signal->SIG_IGN);
Sys::Signal provides the methods to call the system call for the signal.
Sys::Signal
our $SIG_DFL : ro Sys::Signal::Handler::Default;
Gets a singlton Sys::Signal::Handler::Default object that represents SIG_DFL in C Language.
SIG_DFL
C Language
our $SIG_IGN : ro Sys::Signal::Handler::Ignore;
Gets a singlton Sys::Signal::Handler::Ignore object that represents SIG_IGN in C Language.
SIG_IGN
our $SIG_MONITOR : ro Sys::Signal::Handler::Monitor;
Gets a singlton Sys::Signal::Handler::Monitor object to monitor signals.
static method raise : int ($sig : int)
The raise() function sends a signal to the calling process or thread.
See raise(3) - Linux man page in Linux.
Constant values specified in $sig is defined in Sys::Signal::Constant.
$sig
static method kill : int ($pid : int, $sig : int)
The kill() system call can be used to send any signal to any process group or process.
See the kill(2) - Linux man page in Linux.
See Sys::Signal::Constant about the signal numbers specified by $sig
static method alarm : int ($seconds : int)
alarm() arranges for a SIGALRM signal to be delivered to the calling process in seconds seconds.
See alarm(2) - Linux man page in Linux.
Examples:
Sys::Signal->reset_monitored_signal(SIGNAL->SIGALRM); Sys::Signal->signal(SIGNAL->SIGALRM, Sys::Signal->SIG_MONITOR); Sys::Signal->alarm(1); while (1) { if (Sys::Signal->check_monitored_signal(SIGNAL->SIGALRM)) { # Do something } }
static method ualarm : int ($usecs : int, $interval : int)
The ualarm() function causes the signal SIGALRM to be sent to the invoking process after (not less than) usecs microseconds. The delay may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers.
See ualarm(3) - Linux man page in Linux.
static method signal : Sys::Signal::Handler ($signum : int, $handler : Sys::Signal::Handler);
signal() sets the disposition of the signal signum to handler.
See signal(2) - Linux man page in Linux.
Constant values specified in $signum is defined in Sys::Signal::Constant.
$signum
The $handler is a Sys::Signal::Handler object.
$handler
The well known Sys::Signal::Handler classes are Sys::Signal::Handler::Default, Sys::Signal::Handler::Ignore, Sys::Signal::Handler::Monitor, and Sys::Signal::Handler::Unknown.
# SIG_DFL Sys::Signal->signal(SIGNAL->SIGINT, Sys::Signal->SIG_DFL); # SIG_IGN Sys::Signal->signal(SIGNAL->SIGINT, Sys::Signal->SIG_IGN); # Monitor signal Sys::Signal->reset_monitored_signal(SIGNAL->SIGTERM); my $old_handler = Sys::Signal->signal(SIGNAL->SIGTERM, Sys::Signal->SIG_MONITOR); Sys::Signal->raise(SIGNAL->SIGTERM); while (1) { if (Sys::Signal->check_monitored_signal(SIGNAL->SIGTERM)) { # Do something } }
static method reset_monitored_signal : void ($signum : int);
Set a monitored signal by monitored Sys::Signal::Handler::Monitor to 0.
0
static method check_monitored_signal : int ($signum : int);
Gets a monitored signal by monitored Sys::Signal::Handler::Monitor.
If a signal is received, the monitored signal was set to 1 by the Sys::Signal::Handler::Monitor specified in the "signal" method.
1
To install SPVM::Sys, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM::Sys
CPAN shell
perl -MCPAN -e shell install SPVM::Sys
For more information on module installation, please visit the detailed CPAN module installation guide.