From: Ilya Zakharevich Date: Mon, 18 Dec 2006 01:13:59 +0000 (-0800) Subject: SelfLoader after fork() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=add1a1a3c3dc28dd49272f4754cfc04acae28e3b;p=p5sagit%2Fp5-mst-13.2.git SelfLoader after fork() Message-ID: <20061218091359.GA14985@powdermilk.math.berkeley.edu> p4raw-id: //depot/perl@29606 --- diff --git a/lib/SelfLoader.pm b/lib/SelfLoader.pm index ad58f6e..0c2daeb 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}::