Working out an example of non-restarting syscalls I found three
problems.
- sigaction warns if there are no flags in the SigAction structure. I
think the SigAction constructor should treat the SigSet and flags
args as optional. Minimalist patch appended.
$ ./perl -MPOSIX=:signal_h -we '
sigaction 2, new POSIX::SigAction sub { }'
Use of uninitialized value at -e line 1.
$ ./perl -MPOSIX=:signal_h -we '
sigaction 2, new POSIX::SigAction sub { }, undef, 0'
$ _
- POSIX::constant warns on an arg-less macro.
$ ./perl -MPOSIX=:signal_h -lwe 'print SIGALRM'
Use of uninitialized value at /usr/local/lib/perl5/POSIX.pm line 197.
14
$ ./perl -MPOSIX=:signal_h -lwe 'print SIGALRM(0)'
14
$ _
- sigaction doesn't actually work.
$ ./perl -MPOSIX=:signal_h -we '
sigaction SIGALRM(0),
new POSIX::SigAction sub { die "alarm\n" }, undef, 0;
kill "ALRM", $$'
SIGALRM handler "CODE(0x223970)" not defined.
$ _
p5p-msgid: <12808.
852583324@eeyore.ibcinc.com>
package POSIX::SigAction;
sub new {
- bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3]};
+ bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0}, $_[0];
}
############################
C<struct sigaction>. This object will be destroyed automatically when it is
no longer needed. The first parameter is the fully-qualified name of a sub
which is a signal-handler. The second parameter is a C<POSIX::SigSet>
-object. The third parameter contains the C<sa_flags>.
+object, it defaults to the empty set. The third parameter contains the
+C<sa_flags>, it defaults to 0.
- $sigset = POSIX::SigSet->new;
+ $sigset = POSIX::SigSet->new(SIGINT, SIGQUIT);
$sigaction = POSIX::SigAction->new( 'main::handler', $sigset, &POSIX::SA_NOCLDSTOP );
This C<POSIX::SigAction> object should be used with the C<POSIX::sigaction()>