From: Steve Grazzini Date: Wed, 16 Jul 2003 08:56:21 +0000 (-0400) Subject: [DOCPATCH] %SIG and SA_RESTART X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9ce5b4ad89f76922e208c6d250bb5f1abd31555c;p=p5sagit%2Fp5-mst-13.2.git [DOCPATCH] %SIG and SA_RESTART Message-ID: <20030716125620.GA7022@grazzini.net> p4raw-id: //depot/perl@20178 --- diff --git a/pod/perlipc.pod b/pod/perlipc.pod index 48fcb7f..637030c 100644 --- a/pod/perlipc.pod +++ b/pod/perlipc.pod @@ -352,6 +352,20 @@ C<$SIG{ALRM}> try something like the following: sigaction SIGALRM, new POSIX::SigAction sub { die "alarm\n" } or die "Error setting SIGALRM handler: $!\n"; +=item Restartable system calls + +On systems that supported it, older versions of Perl used the +SA_RESTART flag when installing %SIG handlers. This meant that +restartable system calls would continue rather than returning when +a signal arrived. In order to deliver deferred signals promptly, +Perl 5.7.3 and later do I use SA_RESTART. Consequently, +restartable system calls can fail (with $! set to C) in places +where they previously would have succeeded. + +Note that the default C<:perlio> layer will retry C, C +and C as described above and that interrupted C and +C calls will always be retried. + =item Signals as "faults" Certain signals e.g. SEGV, ILL, BUS are generated as a result of diff --git a/pod/perlvar.pod b/pod/perlvar.pod index 4ba6fcf..72cb625 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -1336,24 +1336,11 @@ Be sure not to use a bareword as the name of a signal handler, lest you inadvertently call it. If your system has the sigaction() function then signal handlers are -installed using it. This means you get reliable signal handling. If -your system has the SA_RESTART flag it is used when signals handlers are -installed. This means that system calls for which restarting is supported -continue rather than returning when a signal arrives. If you want your -system calls to be interrupted by signal delivery then do something like -this: - - use POSIX ':signal_h'; - - my $alarm = 0; - sigaction SIGALRM, new POSIX::SigAction sub { $alarm = 1 } - or die "Error setting SIGALRM handler: $!\n"; - -See L. +installed using it. This means you get reliable signal handling. -The delivery policy of signals changed in Perl 5.8.0 from immediate -(also known as "unsafe") to deferred, also known as "safe signals". -See L for more information. +The default delivery policy of signals changed in Perl 5.8.0 from +immediate (also known as "unsafe") to deferred, also known as +"safe signals". See L for more information. Certain internal hooks can be also set using the %SIG hash. The routine indicated by C<$SIG{__WARN__}> is called when a warning message is