perl-docs-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r110120 - /perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod /perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod
Date Tue, 07 Dec 2004 17:52:07 GMT
Author: stas
Date: Tue Dec  7 09:52:06 2004
New Revision: 110120

URL: http://svn.apache.org/viewcvs?view=rev&rev=110120
Log:
update the complicated story of signal handlers

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

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod
Url: http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod?view=diff&rev=110120&p1=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r1=110119&p2=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r2=110120
==============================================================================
--- perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod	(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod	Tue Dec  7 09:52:06 2004
@@ -464,6 +464,56 @@
 modifying the computation logic to explicitly check for the timeout at
 intervals.
 
+Talking about C<alarm()> under prefork mpm, POSIX signals seem to
+work, but require Perl 5.8.x+. For example:
+
+  use POSIX qw(SIGALRM);
+  my $mask      = POSIX::SigSet->new( SIGALRM );
+  my $action    = POSIX::SigAction->new(sub { die "alarm" }, $mask);
+  my $oldaction = POSIX::SigAction->new();
+  POSIX::sigaction(SIGALRM, $action, $oldaction );
+  eval {
+      alarm 2;
+      sleep 10 # some real code should be here
+      alarm 0;
+  };
+  POSIX::sigaction(SIGALRM, $oldaction); # restore original
+  warn "got alarm" if $@ and $@ =~ /alarm/;
+
+For more details see:
+http://search.cpan.org/dist/perl/ext/POSIX/POSIX.pod#POSIX::SigAction.
+
+One could use the C<$SIG{ALRM}> technique, working for 5.6.x+, but it
+works B<only> under DSO modperl build. Moreover 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.
+
+Though if you use perl 5.8.x+ it's preferrable to use the POSIX
+API technique explained earlier in this section.
 
 
 

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=110120&p1=perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod&r1=110119&p2=perl/modperl/docs/trunk/src/docs/2.0/user/troubleshooting/troubleshooting.pod&r2=110120
==============================================================================
--- 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	Tue Dec
 7 09:52:06 2004
@@ -344,61 +344,10 @@
 
 
 
+=head2 Problems with Catching Signals
 
-=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
-
-
-
-
-
+See L<Using Signal
+Handlers|docs::2.0::user::coding::coding/Using_Signal_Handlers>.
 
 
 

---------------------------------------------------------------------
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