develooper Front page | perl.perl5.porters | Postings from August 2002

Re: [PATCH] posixify getppid on linux-multithread

Thread Previous | Thread Next
Rafael Garcia-Suarez
August 9, 2002 00:12
Re: [PATCH] posixify getppid on linux-multithread
Message ID: wrote:
> Rafael Garcia-Suarez <> wrote:
> :Arthur Bergman wrote:
> :> I would store it in ${^PPID} rather than a global PL_ppid variable.
> :
> :The same patch, implemented with ${^PPID} instead of PL_ppid.
> :Note that ${^PPID} is defined only on linux/ithreads.
> I'm not sure that I understand the choice of approach: given the
> title of this thread, it would seem to me to make more sense to
> make POSIX::getpp?id return the real pp?id regardless, and leave
> the inbuilt functions to lie as currently.

Currently $$ and getppid() behave inconsistently. $$ returns the
same number from all threads, getppid() does not.

The POSIX:: counterparts only return $$ and CORE::getppid().

Apparently POSIX requires that getpid() and getppid() return the
same value from different threads.

> If it makes sense to do it this way, why define $^PPID only under
> linux/ithreads? If I want the real ppid I'd have thought it easier
> to need only a single portable mechanism to get it.

${^PPID} is not intended to be used in perl code. It's a way
to store the PPID in a readonly scalar, just like $$ stores the PID.
Of course this can be changed and ${^PPID} can be made user-visible
and be equivalent to getppid().

For portability I think $$ / getppid() should return the same
value from all threads, even on platforms where the underlying
C library doesn't. You can access the underlying C library anyway
(I'll perhaps upload a Linux::pid module to CPAN.)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About