Re: $0 ?

[prev] [thread] [next] [Date index for 2004/12/30]

From: Stas Bekman
Subject: Re: $0 ?
Date: 23:02 on 30 Dec 2004
Torsten Foertsch wrote:
> On Friday 29 October 2004 22:13, Stas Bekman wrote:
> 
>>Torsten Förtsch wrote:
>>
>>>On Friday 29 October 2004 20:17, Stas Bekman wrote:
>>>
>>>>>perl allows to modify $0. Then top, ps & co would display the new
>>>>>process title. Can the process title of a mod_perl modified apache be
>>>>>set this way?
>>>>
> ...
> 
>>>>Take a look at this commit, which might be of some relevance:
>>>>http://marc.theaimsgroup.com/?l=apache-modperl-cvs&m=107672268012042&w=2
>>>
>>>But I see, it is not supported.
>>
>>Due to internal Apache corruptions, no.
> 
> 
> I have just uploaded Sys::Proctitle that modifies the process title at C 
> level. It works only on linux. I have tried it with 2.0.52+mp2-RC1.
> 
> To the internal Apache corruptions: my first attempt was simply to make a copy 
> of __environ via malloc() and strdup(). With pure perl that worked but with 
> apache/mod_perl it gave segfaults or double free messages from glibc 
> depending on the require'ing or use'ing of the module. Some poking on 
> putenv/getenv/setenv source code revealed big magic and led me to the 
> following approach of copying the environment:
> 
>     clearenv();
>     for( i=0; envp[i]; i++ ) {
>       char *cp=strchr( envp[i], '=' );
>       if( cp ) {
> 	*cp++='\0';
> 	setenv( envp[i], cp, 1 );
>       }
>     }

where is the copy? I don't see any data allocated.

> clearenv() simply sets __environ=NULL. setenv() then builds a new environment.
> 
> I don't know anything about how mp2 and apache interact regarding the 
> environment. But maybe it helps to let $0 be assigned to in mod_perl.

You don't want to know :)

As you can see from the email you've quoted the problem is really coming 
from Perl, not Apache.

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

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

(message missing)

$0 ?
Torsten =?iso-8859-1?q?F=F6rtsch?= 17:37 on 29 Oct 2004

Re: $0 ?
Stas Bekman 18:17 on 29 Oct 2004

Re: $0 ?
Torsten =?iso-8859-1?q?F=F6rtsch?= 18:40 on 29 Oct 2004

Re: $0 ?
Stas Bekman 20:13 on 29 Oct 2004

Re: $0 ?
Pratik 20:21 on 29 Oct 2004

Re: $0 ?
Torsten Foertsch 15:18 on 30 Dec 2004

Some tests failed: mod_perl-2.0.0-RC2-XMas on FC3
Patrick LeBoutillier 16:30 on 30 Dec 2004

Re: $0 ?
Stas Bekman 23:02 on 30 Dec 2004

Re: $0 ?
David Nicol 00:21 on 30 Oct 2004

Generated at 12:16 on 16 Jan 2005 by mariachi v0.52