perl-docs-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r106429 - /perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod
Date Wed, 24 Nov 2004 16:52:17 GMT
Author: stas
Date: Wed Nov 24 08:52:16 2004
New Revision: 106429

URL: http://svn.apache.org/viewcvs?view=rev&rev=106429
Log:
Problems with Catching Signals under Perl 5.8.x+

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod
Url: http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod?view=diff&rev=106429&p1=perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod&r1=106428&p2=perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod&r2=106429
==============================================================================
--- perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod	(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod	Wed Nov
24 08:52:16 2004
@@ -363,6 +363,68 @@
 
 
 
+
+=head2 Problems with Catching Signals under Perl 5.8.x+
+
+Starting from 5.8.0 Perl delays signal delivery, making signals
+safe. This change may break previously working code.  For more
+information please see:
+http://search.cpan.org/dist/perl/pod/perl58delta.pod#Safe_Signals and
+http://search.cpan.org/dist/perl/pod/perlipc.pod#Deferred_Signals_%28Safe_Signals%29
+
+For example if you had the alarm code:
+
+  eval {
+      local $SIG{ALRM} = sub { die "alarm" };
+      alarm 3;
+      sleep 10; # in reality some real code should be here
+      alarm 0;
+  };
+  die "the operation was aborted" if $@ and $@ =~ /alarm/;
+
+It may not work anymore. Starting from 5.8.1 it's possible to
+circumvent the safeness of signals, by setting:
+
+  $ENV{PERL_SIGNALS} = "unsafe";
+
+as soon as you start your program (e.g. in the case of mod_perl in
+startup.pl).
+
+For more information please refer to:
+http://search.cpan.org/dist/perl/pod/perl581delta.pod#Unsafe_signals_again_available
+and http://search.cpan.org/dist/perl/pod/perlrun.pod#PERL_SIGNALS
+
+But most likely this is not what you want (since that circumvention
+makes your code unsafe). The proper solution that works correctly
+across all 5.8.x+ versions is to use the POSIX signal handling, which
+bypasses perl signal mechanism. Our example should be rewritten as
+follows:
+
+  use POSIX qw(SIGALRM);
+  eval {
+      POSIX::sigaction(SIGALRM,
+                       POSIX::SigAction->new(sub { die "alarm" }))
+            or die "Error setting SIGALRM handler: $!\n";
+      alarm 3;
+      sleep 10; # in reality some real code should be here
+      alarm 0;
+  };
+  die "the operation was aborted" if $@ and $@ =~ /alarm/;
+
+For more details see:
+http://search.cpan.org/dist/perl/ext/POSIX/POSIX.pod#POSIX::SigAction
+
+
+
+
+
+
+
+
+
+
+
+
 =head2 APR::Socket::recv: (11) Resource temporarily unavailable at ...
 
 You need to make sure that the socket is set to L<blocking IO

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-cvs-help@perl.apache.org


Mime
View raw message