Mailing List Archive

Re: mod_perl and $0
On 04/12/2013 09:15 AM, Michiel Beijen wrote:
> Hi,
>
> According to perldoc perlvar the special variable $0 "Contains the
> name of the program being executed".
>
> My application uses $0 and FindBin to add some relative subdirectories
> to @INC. This works fine in CGI context, and when scripts are run from
> the command line, but under mod_perl $0 actually contains the Apache
> configuration file, so this does not work correctly. We fix this by
> performing 'use lib' with the actual directory names in the apache
> perl startup file.
>
> Now Fedora (Jan Kaluza) added a patch to their mod_perl package to set
> $0 to 'httpd' which is done I think in order to have a nice process
> list:
>
> http://pkgs.fedoraproject.org/cgit/mod_perl.git/commit/mod_perl-short-name.patch?id=e18c20f9e3cdc3e062f75e8d54fdd4520d2f719f

This was done mainly to fix
https://bugzilla.redhat.com/show_bug.cgi?id=782369 , but as you stated
below, during my work on porting mod_perl to httpd24, I have found out
the same thing as you and currently in F18+ this patch is not applied:

http://pkgs.fedoraproject.org/cgit/mod_perl.git/tree/mod_perl.spec#n81

> The problem with that is that it is no longer a valid path, so if we
> use FindBin it dies.
>
> I now worked around it by determining if $0 is a valid path and if not
> by assigning to it in a BEGIN block. Now mod_perl can at least start
> again on Fedora.
>
> Two questions:
>
> A: is it conceivable that we fix mod_perl so that it actually returns
> the correct value for $0?
> B: is the downstream patch Fedora uses for setting $0 to 'httpd' dersirable?
>
> --
> Mike
>

Jan Kaluza


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: mod_perl and $0 [ In reply to ]
On 15/04/13 08:12, Jan Kaluža wrote:
> A: is it conceivable that we fix mod_perl so that it actually returns
> the correct value for $0?

I probably missed the original mail. Sorry about that.

But what would the "correct value of $0" be?

For registry scripts I can imagine something similar to $SCRIPT_FILENAME
in CGI scripts. But how about modperl handlers or request phases other
than response or even phases outside the request cycle?

And 2nd, should that value show up in top/ps?

By the way it came never to my mind to check the value of $^X in
mod_perl. Turns out it points to the httpd binary. I think that is worth
to be fixed. But how? I think we can get at the path of the libperl.so.
But how to deduce a perl binary from that? The only way I can see is to
set a constant value at compile time. In fact, a perl binary doesn't
even need to exist.

Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org