develooper Front page | perl.perl5.porters | Postings from November 2004

[patch pod/perlipc] use POSIX; w/o () is a bad idea

Thread Next
From:
Stas Bekman
Date:
November 24, 2004 08:25
Subject:
[patch pod/perlipc] use POSIX; w/o () is a bad idea
Message ID:
41A4B5EA.3020804@stason.org
For those who aren't aware how bad 'use POSIX;' is (w/o explicit or empty 
import list) please read:
http://perl.apache.org/docs/1.0/guide/performance.html#Global_vs__Fully_Qualified_Variables

Here is the fix (and I've also made it a bit more clear what part of the 
SIG catching technique is replaced):

--- pod/perlipc.pod.orig    2004-11-24 11:07:56.812300701 -0500
+++ pod/perlipc.pod 2004-11-24 11:21:25.340831776 -0500
@@ -355,11 +355,16 @@
  you can try using the POSIX sigaction() function, which bypasses the
  Perl safe signals (note that this means subjecting yourself to
  possible memory corruption, as described above).  Instead of setting
-C<$SIG{ALRM}> try something like the following:
+C<$SIG{ALRM}>:

-    use POSIX;
-    sigaction SIGALRM, new POSIX::SigAction sub { die "alarm\n" }
-        or die "Error setting SIGALRM handler: $!\n";
+   local $SIG{ALRM} = sub { die "alarm" };
+
+try something like the following:
+
+    use POSIX qw(SIGALRM);
+    POSIX::sigaction(SIGALRM,
+                     POSIX::SigAction->new(sub { die "alarm" }))
+          or die "Error setting SIGALRM handler: $!\n";

  =item Restartable system calls


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About