httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestServer.pm
Date Sun, 06 Jan 2002 07:09:21 GMT
Doug MacEachern wrote:

> On Fri, 4 Jan 2002, Stas Bekman wrote:
>  
> 
>>Any idea how to disable the END blocks inheritance in the forked child? 
>>
> 
> my $Pid = $$;
> 
> sub is_parent {
>     $$ == $Pid;
> }
> 
> my $pid = fork;
> 
> exit unless $pid;
> 
> END {
>     print "END pid=$$\n";
>     return unless is_parent();
>     print "stuff\n";
> }
> 
> prints:
> END pid=2687
> END pid=2688
> stuff
> 
> without 'return unless is_parent()' prints 'stuff' twice.


nice :) I was thinking there is some magic way to tell Perl not to run END block.


I've done with this:


-    eval 'END {
+    eval 'my $parent_pid = $$;
+          END {
+             return unless $$ == $parent_pid; # because of fork
               local $?; # preserve the exit status

-- 


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Mime
View raw message