Re: $0 ?
[prev]
[thread]
[next]
[Date index for 2004/12/30]
--nextPart2651036.bakVOKTtNY
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
On Friday 29 October 2004 22:13, Stas Bekman wrote:
> Torsten F=F6rtsch 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?
> >>
=2E..
> >>Take a look at this commit, which might be of some relevance:
> >>http://marc.theaimsgroup.com/?l=3Dapache-modperl-cvs&m=3D10767226801204=
2&w=3D2
> >
> > 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=20
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 c=
opy=20
of __environ via malloc() and strdup(). With pure perl that worked but with=
=20
apache/mod_perl it gave segfaults or double free messages from glibc=20
depending on the require'ing or use'ing of the module. Some poking on=20
putenv/getenv/setenv source code revealed big magic and led me to the=20
following approach of copying the environment:
clearenv();
for( i=3D0; envp[i]; i++ ) {
char *cp=3Dstrchr( envp[i], '=3D' );
if( cp ) {
*cp++=3D'\0';
setenv( envp[i], cp, 1 );
}
}
clearenv() simply sets __environ=3DNULL. setenv() then builds a new environ=
ment.
I don't know anything about how mp2 and apache interact regarding the=20
environment. But maybe it helps to let $0 be assigned to in mod_perl.
Again, the module is very linux specific.
As an example of using Sys::Proctitle I have uploaded Apache::ShowStatus. I=
t=20
provides a PerlInitHandler that places a Sys::Proctitle object in $r->pnote=
s=20
changing the command line to "httpd: ".$r->the_request. When the request is=
=20
deleted the object is destroyed and the command line is changed back.=20
Obviously this makes sense only with prefork mpm.
Torsten
--nextPart2651036.bakVOKTtNY
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQBB1Bw3wicyCTir8T4RAsmPAJwOs+kJBZJRjCIXi8gTovZpRzQDQgCfYZqx
LZoN4BOa+QaAg1w4qauWhco=
=shuG
-----END PGP SIGNATURE-----
--nextPart2651036.bakVOKTtNY--
 |
(message missing)
|
 |
 |
$0 ?
Torsten =?iso-8859-1?q?F=F6rtsch?= 17:37 on 29 Oct 2004
|