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.
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);
All methods can be called either as class methods, or as object methods on the
Returns the instance of this module.
Blocks the set of signals given in the
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.
You can contribute or fork this project via github:
Please report any bugs or feature requests to email@example.com, or through the web interface at http://rt.cpan.org/.
Michael Schout <firstname.lastname@example.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: