New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[patch] [resend] Turn $$ into a magical readonly variable that always fetches getpid() instead of caching it #11179
Comments
From @CorionCreated by @CorionTo get a Perlbug number, I'm resending the patch appended commit df1cd6761ac9224f4aea7139509f9cacbf0b9ea0 Turn $$ into a magical readonly variable that always fetches The intent is that by not caching $$, we eliminate one opportunity Inline Patchdiff --git a/gv.c b/gv.c
index 4e79171..f11f0cc 100644
--- a/gv.c
+++ b/gv.c
@@ -1457,6 +1457,8 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg,
+ case '$': /* $$ */ Inline Patchdiff --git a/mg.c b/mg.c
index 8053bf1..89c22c6 100644
--- a/mg.c
+++ b/mg.c
@@ -1115,6 +1115,12 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
if (PL_ors_sv)
sv_copypv(sv, PL_ors_sv);
break;
+ case '$': /* $$ */
+ sv_setiv(sv, (IV)PerlProc_getpid());
+ /* If you want another number, pull one at the entrance */
+ SvREADONLY_on(sv);
+ break;
+
case '!':
{
dSAVE_ERRNO;
diff --git a/perl.c b/perl.c
index d2571a8..ab2e079 100644
--- a/perl.c
+++ b/perl.c
@@ -4125,11 +4125,6 @@ S_init_postdump_symbols(pTHX_ register int argc,
Inline Patchdiff --git a/pp_sys.c b/pp_sys.c
index 2845266..c4998bb 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4084,12 +4084,6 @@ PP(pp_fork)
if (childpid < 0)
RETSETUNDEF;
if (!childpid) {
- GV * const tmpgv = gv_fetchpvs("$", GV_ADD|GV_NOTQUAL, SVt_PV);
- if (tmpgv) {
- SvREADONLY_off(GvSV(tmpgv));
- sv_setiv(GvSV(tmpgv), (IV)PerlProc_getpid());
- SvREADONLY_on(GvSV(tmpgv));
- }
#ifdef THREADS_HAVE_PIDS
PL_ppid = (IV)getppid();
#endif
diff --git a/util.c b/util.c
index ac7dd57..b175c31 100644
--- a/util.c
+++ b/util.c
@@ -2770,12 +2770,6 @@ Perl_my_popen(pTHX_ const char *cmd, const char
Inline Patchdiff --git a/win32/perlhost.h b/win32/perlhost.h
index 70a2f65..8103ee7 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -1722,18 +1722,11 @@ win32_start_child(LPVOID arg)
PERL_SET_THX(my_perl);
win32_checkTLS(my_perl);
- /* set $$ to pseudo id */
#ifdef PERL_SYNC_FORK
w32_pseudo_id = id;
#else
w32_pseudo_id = GetCurrentThreadId();
#endif
- if (tmpgv = gv_fetchpv("$", TRUE, SVt_PV)) {
- SV *sv = GvSV(tmpgv);
- SvREADONLY_off(sv);
- sv_setiv(sv, -(IV)w32_pseudo_id);
- SvREADONLY_on(sv);
- }
#ifdef PERL_USES_PL_PIDSTATUS
hv_clear(PL_pidstatus);
#endif Perl Info
|
From @exodistI am indifferent about this patch, but I want to point out that use of Once again I am indifferent to the patch, I doubt the performance hit -Chad 'Exodist' Granum On Sun, Mar 6, 2011 at 10:20 AM, Max Maischein
|
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Sun Mar 06 10:20:12 2011, corion@cpan.org wrote:
Is there any reason I should not apply this? |
From @cpansproutAnother message that RT didn’t pick up, from Hello,
I'm unaware of any such reason. I couldn't get a reply either for or Still I think it should get applied, as the two CPAN modules affected by -max |
From @cpansproutOn Sun May 22 18:07:52 2011, sprout wrote:
I’ve just applied it as 0e21945. I tweaked it a bit, as your version was Thank you! |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#85520 (status was 'resolved')
Searchable as RT85520$
The text was updated successfully, but these errors were encountered: