diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 2006-12-17 17:13:59 -0800 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2006-12-21 05:47:31 +0000 |
commit | add1a1a3c3dc28dd49272f4754cfc04acae28e3b (patch) | |
tree | 6635e3f4b4059ad26f934169ecd14c1241d12169 | |
parent | 542cb85fb9a8a115820bc461945b228d531b4059 (diff) | |
download | perl-add1a1a3c3dc28dd49272f4754cfc04acae28e3b.tar.gz |
SelfLoader after fork()
Message-ID: <20061218091359.GA14985@powdermilk.math.berkeley.edu>
p4raw-id: //depot/perl@29606
-rw-r--r-- | lib/SelfLoader.pm | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/SelfLoader.pm b/lib/SelfLoader.pm index ad58f6e8da..0c2daebc83 100644 --- a/lib/SelfLoader.pm +++ b/lib/SelfLoader.pm @@ -60,6 +60,11 @@ sub _load_stubs { print STDERR "SelfLoader::load_stubs($callpack)\n" if $DEBUG; croak("$callpack doesn't contain an __DATA__ token") unless defined fileno($fh); + # Protect: fork() shares the file pointer between the parent and the kid + open my $nfh, '<&', $fh or croak "reopen: $!";# dup() the fd + close $fh or die "close: $1"; # autocloses, but be paranoid + open $fh, '<&', $nfh or croak "reopen2: $!"; # dup() the fd "back" + close $nfh or die "close after reopen: $1"; # autocloses, but be paranoid $Cache{"${currpack}::<DATA"} = 1; # indicate package is cached local($/) = "\n"; |