This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Turn $$ into a magical readonly variable that always fetches getpid() instead of...
[perl5.git] / mg.c
diff --git a/mg.c b/mg.c
index 85b5461..af2c647 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1114,6 +1114,10 @@ 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());
+       break;
+
     case '!':
        {
        dSAVE_ERRNO;