From: Roderick Schertler Date: Mon, 6 Jan 1997 20:42:04 +0000 (-0500) Subject: sigaction() problems X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=84e96f2bcc509ba2fb5d2c9608a30cc3cfdea41a;p=p5sagit%2Fp5-mst-13.2.git sigaction() problems 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> --- diff --git a/ext/POSIX/POSIX.pm b/ext/POSIX/POSIX.pm index 22eed02..f99b9e7 100644 --- a/ext/POSIX/POSIX.pm +++ b/ext/POSIX/POSIX.pm @@ -231,7 +231,7 @@ sub unimpl { package POSIX::SigAction; sub new { - bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3]}; + bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0}, $_[0]; } ############################ diff --git a/ext/POSIX/POSIX.pod b/ext/POSIX/POSIX.pod index 2bb8743..0578d49 100644 --- a/ext/POSIX/POSIX.pod +++ b/ext/POSIX/POSIX.pod @@ -1314,9 +1314,10 @@ Creates a new C object which corresponds to the C C. 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 -object. The third parameter contains the C. +object, it defaults to the empty set. The third parameter contains the +C, 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 object should be used with the C