summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorMax Maischein <corion@corion.net>2011-05-22 21:36:57 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-05-22 21:50:50 -0700
commit0e21945565eb4664d843bb819fb032cedee4d5a6 (patch)
treeb5b5ab6ecccabc65812e44ac0a5baefa3f5e5000 /util.c
parent369fb445f856204b1f9717b96bde7cd9bb9da369 (diff)
downloadperl-0e21945565eb4664d843bb819fb032cedee4d5a6.tar.gz
Turn $$ into a magical readonly variable that always fetches getpid() instead of caching it
The intent is that by not caching $$, we eliminate one opportunity for bugs: If one embeds Perl or uses XS and calls fork(3) from C, Perls notion of $$ may go out of sync with what getpid() returns. By always fetching the value of $$ via getpid(), this bug opportunity is eliminated. The overhead of always fetching $$ should be small and is likely only used for tempfile creation, which should be dwarfed by file system accesses.
Diffstat (limited to 'util.c')
-rw-r--r--util.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/util.c b/util.c
index bd9010f5ca..f6742e70b4 100644
--- a/util.c
+++ b/util.c
@@ -2759,12 +2759,6 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode)
default, binary, low-level mode; see PerlIOBuf_open(). */
PerlLIO_setmode((*mode == 'r'), O_BINARY);
#endif
-
- if ((tmpgv = gv_fetchpvs("$", GV_ADD|GV_NOTQUAL, SVt_PV))) {
- SvREADONLY_off(GvSV(tmpgv));
- sv_setiv(GvSV(tmpgv), PerlProc_getpid());
- SvREADONLY_on(GvSV(tmpgv));
- }
#ifdef THREADS_HAVE_PIDS
PL_ppid = (IV)getppid();
#endif