NAME
Sys::Signals::Block - Simple interface to block delivery of signals
SYNOPSIS
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;
DESCRIPTION
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.
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:
# 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);
METHODS
All methods can be called either as class methods, or as object methods on the <Sys::Signals::Block-
instance>> object.
- instance()
-
Returns the instance of this module.
- block()
-
Blocks the set of signals given in the
use
line. - unblock()
-
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.
TODO
Add ability to change the set of signals that should be blocked at runtime.
SOURCE
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
BUGS
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/.
AUTHOR
Michael Schout <mschout@cpan.org>
COPYRIGHT AND LICENSE
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.