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:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Reply via email to