From: Michael G. Schwern Date: Sat, 24 Nov 2001 19:56:18 +0000 (-0500) Subject: $$ readonly, take two X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=306196c33b5ac60c7c253de83663fec31448e22d;p=p5sagit%2Fp5-mst-13.2.git $$ readonly, take two Message-ID: <20011124195618.A14614@blackrider> p4raw-id: //depot/perl@13252 --- diff --git a/perl.c b/perl.c index 14fda35..9d493ad 100644 --- a/perl.c +++ b/perl.c @@ -3565,8 +3565,11 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register #endif /* USE_ENVIRON_ARRAY */ } TAINT_NOT; - if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) + if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) { + SvREADONLY_off(GvSV(tmpgv)); sv_setiv(GvSV(tmpgv), (IV)PerlProc_getpid()); + SvREADONLY_on(GvSV(tmpgv)); + } } STATIC void diff --git a/pp_sys.c b/pp_sys.c index bf2b352..4b9b096 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -3923,8 +3923,11 @@ PP(pp_fork) RETSETUNDEF; if (!childpid) { /*SUPPRESS 560*/ - if ((tmpgv = gv_fetchpv("$", TRUE, SVt_PV))) + if ((tmpgv = gv_fetchpv("$", TRUE, SVt_PV))) { + SvREADONLY_off(GvSV(tmpgv)); sv_setiv(GvSV(tmpgv), (IV)PerlProc_getpid()); + SvREADONLY_on(GvSV(tmpgv)); + } hv_clear(PL_pidstatus); /* no kids, so don't wait for 'em */ } PUSHi(childpid); diff --git a/t/op/magic.t b/t/op/magic.t index 4e47414..4f38623 100755 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -36,7 +36,7 @@ sub skip { return 1; } -print "1..43\n"; +print "1..44\n"; $Is_MSWin32 = $^O eq 'MSWin32'; $Is_NetWare = $^O eq 'NetWare'; @@ -143,6 +143,8 @@ eval { die "foo\n" }; ok $@ eq "foo\n", $@; ok $$ > 0, $$; +eval { $$++ }; +ok $@ =~ /^Modification of a read-only value attempted/; # $^X and $0 { diff --git a/util.c b/util.c index 4f3e092..01238b8 100644 --- a/util.c +++ b/util.c @@ -2057,8 +2057,11 @@ Perl_my_popen(pTHX_ char *cmd, char *mode) } #endif /* defined OS2 */ /*SUPPRESS 560*/ - if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) + if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) { + SvREADONLY_off(GvSV(tmpgv)); sv_setiv(GvSV(tmpgv), PerlProc_getpid()); + SvREADONLY_on(GvSV(tmpgv)); + } PL_forkprocess = 0; hv_clear(PL_pidstatus); /* we have no children */ return Nullfp;