| 1 | package Linux::Perl::sigprocmask; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | =encoding utf-8 | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | Linux::Perl::sigprocmask | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | # These all return the complete former signal mask (as numbers) | ||||||||||||||||||||
| 15 | # when called in list context. | ||||||||||||||||||||
| 16 | @oldlist = Linux::Perl::sigprocmask->block( 2, 'USR1' ); | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | Linux::Perl::sigprocmask->block( 2, 'USR1' ); | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | Linux::Perl::sigprocmask->unblock( 2, 'USR1' ); | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | Linux::Perl::sigprocmask->set( 2, 'USR1' ); | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | An implementation of the kernel’s logic to set the signal mask. | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 6 | ▶ | use Linux::Perl; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 6 | ▶ | use Linux::Perl::SigSet; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | use constant { | ||||||||||||||||||||
| 34 | 6 | _SIG_BLOCK => 0, | |||||||||||||||||||
| 35 | _SIG_UNBLOCK => 1, | ||||||||||||||||||||
| 36 | _SIG_SETMASK => 2, | ||||||||||||||||||||
| 37 | 6 | ▶ | }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =head1 METHODS | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =head2 I<CLASS>->block( @SIGNALS ) | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | Add to the list of currently blocked signals. | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | The return in list context is the group of signals that, | ||||||||||||||||||||
| 48 | prior to this function call, were blocked. (Signals are | ||||||||||||||||||||
| 49 | referenced by number only.) | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | sub block { | ||||||||||||||||||||
| 54 | 8 | ▶ | return $_[0]->_do( | ||||||||||||||||||
|
Subroutine
block: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 55 | _SIG_BLOCK(), | ||||||||||||||||||||
| 56 | @_[ 1 .. $#_ ], | ||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head2 I<CLASS>->unblock( @SIGNALS ) | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | The inverse of C<block()>. | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =cut | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | sub unblock { | ||||||||||||||||||||
| 69 | 2 | ▶ | return $_[0]->_do( | ||||||||||||||||||
|
Subroutine
unblock: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 70 | _SIG_UNBLOCK(), | ||||||||||||||||||||
| 71 | @_[ 1 .. $#_ ], | ||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =head2 I<CLASS>->set( @SIGNALS ) | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | Like C<block()> and C<unblock()> but sets/clobbers the entire set | ||||||||||||||||||||
| 80 | of blocked signals. | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | sub set { | ||||||||||||||||||||
| 85 | 6 | ▶ | return $_[0]->_do( | ||||||||||||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 86 | _SIG_SETMASK(), | ||||||||||||||||||||
| 87 | @_[ 1 .. $#_ ], | ||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | #---------------------------------------------------------------------- | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | sub _do { | ||||||||||||||||||||
| 94 | 16 | ▶ | my ($class, $how, @signals) = @_; | ||||||||||||||||||
|
Subroutine
_do: called CC=4 SCAR=13.9
| |||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 16 | my $mask = Linux::Perl::SigSet::from_list(@signals); | |||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 16 | my $oldmask = "\0" x length($mask); | |||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 16 | ▶ | my $arch_module = ($class ne __PACKAGE__) && $class; | ||||||||||||||||||
|
Condition66%2/3
$class ne __PACKAGE__ && $class
MC/DC50%1/2
$class ne __PACKAGE__ && $class
$class ne __PACKAGE__
$class
Truth table66%2/3
A && B
A= $class ne __PACKAGE__B= $class
| |||||||||||||||||||||
| 101 | 16 | ▶ | $arch_module ||= do { | ||||||||||||||||||
|
Condition66%2/3
$arch_module ||= do {
require Linux::Perl::ArchLoader;
Linux::Perl::ArchLoader::get_arch_module($class)
}
MC/DC0%0/2
$arch_module ||= do {
require Linux::Perl::ArchLoader;
Linux::Perl::ArchLoader::get_arch_module($class)
}
$arch_module
do {
require Linux::Perl::ArchLoader;
Linux::Perl::ArchLoader::get_arch_module($class)
}
Truth table66%2/3
A ||= B
A= $arch_moduleB= do {
require Linux::Perl::ArchLoader;
Linux::Perl::ArchLoader::get_arch_module($class)
}
| |||||||||||||||||||||
| 102 | 10 | require Linux::Perl::ArchLoader; | |||||||||||||||||||
| 103 | 10 | Linux::Perl::ArchLoader::get_arch_module($class); | |||||||||||||||||||
| 104 | }; | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 16 | Linux::Perl::call( | |||||||||||||||||||
| 107 | $arch_module->NR_rt_sigprocmask(), | ||||||||||||||||||||
| 108 | 0 + $how, | ||||||||||||||||||||
| 109 | $mask, | ||||||||||||||||||||
| 110 | $oldmask, | ||||||||||||||||||||
| 111 | length $mask, | ||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 16 | ▶ | return wantarray ? Linux::Perl::SigSet::to_list($oldmask) : undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 115 | } | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 6 | 1; | |||||||||||||||||||