develooper Front page | perl.perl5.porters | Postings from December 2010

Re: Turn $$ into a magical readonly variable that always fetches getpid()

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
December 30, 2010 13:59
Subject:
Re: Turn $$ into a magical readonly variable that always fetches getpid()
Message ID:
AANLkTimcQPzdJNQcJVCRNc29ESTFMYyBP0+inrpPup42@mail.gmail.com
On Thu, Dec 30, 2010 at 10:16 PM, Paul LeoNerd Evans
<leonerd@leonerd.org.uk> wrote:
> Purely idle speculation, but if $$ behaves this way currently, what of
> $< $> $( $)  ? Do these cache their values, or are they magical to
> get{,e}{u,g}id() ?
>
> I'll go off sourcediving in a moment once I've finished some unrelated
> stuff and take a look...

Those seem to be cached in PL_uid, PL_euid, PL_gid and PL_egid. The
latter two have the interesting feature of having the numerical value
from that cache but its string value is fresh from getgroups(3) if
that is available. I haven't tested it, but I suspect they have
similar issues. Some other codepaths also use those variables, so
simply getting rid of them is unlikely to solve the problem. Unlike $$
I've never heard of a anyone who ran into issues due to this though.

Leon

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About