Attribute::SigHandler - A Signal Handler Attribute


Attribute-Util documentation Contained in the Attribute-Util distribution.

Index


Code Index:

NAME

Top

Attribute::SigHandler - A Signal Handler Attribute

SYNOPSIS

Top

  use Attribute::SigHandler;

  sub myalrm : SigHandler(ALRM, VTALRM) { ...  }
  sub mywarn : SigHandler(__WARN__) { ... }

DESCRIPTION

Top

When used on a subroutine, this attribute declares that subroutine to be a signal handler for the signal(s) given as options for this attribute. It thereby frees you from the implementation details of defining sig handlers and keeps the handler definitions where they belong, namely with the handler subroutine.

BUGS

Top

None known so far. If you find any bugs or oddities, please do inform the author.

AUTHOR

Top

Marcel Grunauer, <marcel@codewerk.com>

Dan Kogai, <dankogai@dan.co.jp>

COPYRIGHT

Top

SEE ALSO

Top

perl(1), Attribute::Handlers


Attribute-Util documentation Contained in the Attribute-Util distribution.

package Attribute::SigHandler;

use warnings;
use strict;
use Attribute::Handlers;

our $VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)/g;

sub UNIVERSAL::SigHandler : ATTR(CODE) {
	my ($symbol, $data) = @_[1,4];
	$SIG{$_} = *{$symbol}{NAME} for ref $data eq 'ARRAY' ? @$data : $data;
}

"Rosebud"; # for MARCEL's sake, not 1 -- dankogai

__END__