in reply to Perl 5.15.0 is now available

$$ no longer caches PID

Can anyone explain why this was done, and what is the new method for obtaining the pid of the script?


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Perl 5.15.0 is now available
by Corion (Patriarch) on Jun 21, 2011 at 12:14 UTC

    I introduced this change, so I guess I should explain the idea behind it:

    The old method of using $$ is still the way to get at your scripts PID. The only change is that the value of $$ is directly retrieved from getpid instead of being cached.

    It used to be (up to 5.14.x) that $$ gets the value of getpid() and caches it at program start or at the first read. Whenever the Perl script calls fork, the cache needed to be updated. This opened a bug opportunity when a module called POSIX::fork or called fork(3) directly, and forgot to update the cached value.