Sys::Signals::Block - Simple interface to block delivery of signals
use Sys::Signals::Block qw(TERM INT); Sys::Signals::Block->block; # critical section. # SIGINT, SIGTERM will not be delivered Sys::Signals::Block->unblock; # signals sent during critical section will be delivered here # or if you prefer object syntax: my $sigs = Sys::Signals::Block->instance; $sigs->block; # critical section $sigs->unblock;
This module provides an easy way to block the delivery of certain signals. This is essentially just a wrapper around POSIX::sigprocmask(SIG_BLOCK, ...) and POSIX::sigprocmask(SIG_UNBLOCK, ...), but with a much simpler API.
POSIX::sigprocmask(SIG_BLOCK, ...)
POSIX::sigprocmask(SIG_UNBLOCK, ...)
The set of signals that should be blocked are given in the import list (the parameters in the use line for the module). The signal values can be either numeric, or string names. If names are given, they may be given either with or without the SIG prefix. For example, the following are all equivalent:
use
SIG
# names, no SIG prefix use Sys::Signals::Block qw(TERM INT); # names with SIG prefix use Sys::Signals::Block qw(SIGTERM SIGINT); # integers, using POSIX constants use Sys::Signals::Block (POSIX::SIGTERM, POSIX::SIGINT);
All methods can be called either as class methods, or as object methods on the <Sys::Signals::Block-instance>> object.
<Sys::Signals::Block-
Returns the instance of this module.
Blocks the set of signals given in the use line.
Unblocks the set of signals given in the use line. Any signals that were not delivered while signals were blocked will be delivered once the signals are unblocked.
Add ability to change the set of signals that should be blocked at runtime.
You can contribute or fork this project via github:
http://github.com/mschout/sys-signals-block
git clone git://github.com/mschout/sys-signals-block.git
Please report any bugs or feature requests to bug-sys-signals-block@rt.cpan.org, or through the web interface at http://rt.cpan.org/.
Michael Schout <mschout@cpan.org>
Copyright (C) 2009 by Michael Schout
This program is free software; you can redistribute it and/or modify it under the terms of either:
the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or
the Artistic License version 2.0.
"SigSet" in POSIX, "sigprocmask" in POSIX
To install Sys::Signals::Block, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sys::Signals::Block
CPAN shell
perl -MCPAN -e shell install Sys::Signals::Block
For more information on module installation, please visit the detailed CPAN module installation guide.