develooper Front page | perl.perl5.porters | Postings from October 2003

[5.8.1] getppid is not maintained if not forked by perl

Thread Next
From:
Stas Bekman
Date:
October 16, 2003 11:02
Subject:
[5.8.1] getppid is not maintained if not forked by perl
Message ID:
3F8EDD22.6010406@stason.org
It looks like 5.8.1 started to cache ppids in PL_ppid, which wasn't the case 
in 5.8.0. When ithreads are enabled the new logic updates PL_ppid in pp_fork, 
which now does:

PP(pp_fork)
{
...
#ifdef THREADS_HAVE_PIDS
	PL_ppid = (IV)getppid();
#endif
...

So if an application running embedded perl wasn't forked by perl's pp_fork, 
it'll have this problem. Under mod_perl 2, we get getppid reporting 1 from the 
forked process, when pstree clearly shows that this is not the case.

I have a workaround for mp2:

#if PERL_REVISION == 5 && PERL_VERSION == 8 && PERL_SUBVERSION == 1
     {
#ifdef THREADS_HAVE_PIDS
#ifdef USE_ITHREADS
         MP_dSCFG(s);
         dTHXa(scfg->mip->parent->perl);
         PL_ppid = (IV)getppid();
#endif
#endif
     }
#endif

which can be run at the child_init phase, immediately after a new process is 
forked. But may be it's something that need to be fixed in perl, as it worked 
just fine with 5.8.0, and is probably an inappropriate change in behavior for 
a maintenance release? If not please let me know, so that I'll change the 
workaround's ifdef to match 5.8.1+.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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