You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by pradeep kumar <pr...@gmail.com> on 2005/11/08 10:28:40 UTC

Re: [mp2] Directive changes the command nam

I tried to read the whole of argv and push it in
modperl_config_srv_argv_push(). But what I can get only upto
"/app/apache/bin/httpd -d /app/apache" and not the whole of
"/app/apache/bin/httpd -d /app/apache -k start". I tried to print argv[3]
which just gave me null. How can I get the rest of the arguments.

On 10/12/05, Philippe M. Chiasson <go...@ectoplasm.org> wrote:
>
> pradeep kumar wrote:
> > Hi,
> >
> > I got the fix from http://svn.apache.org/viewcvs.cgi?view=rev&rev=291193
> > <http://svn.apache.org/viewcvs.cgi?view=rev&rev=291193>. This solves the
> > problem partially. I used that fix. But this gives only the command name
> > instead of the whole of the command line.
>
> Yes, that an unfortunate side effect of how perl_parse functions.
>
> The typical embedder's method of calling perl_parse() like this:
> perl_parse(my_perl, NULL, 3, {"", "-e","0" }, NULL);
>
> Causes a side effect of setting $0 to '-e', which in turn, on HPUX
> will call pstat(PSTAT_SETCMD, [...]); Causing the original problem.
>
> The _only_ solution I can currently think of is what I implemented.
> Reset $0 to argv[0]. And that's why you see only the name of the binary.
>
> I am not sure if this could be somehow fixed by resetting $0 not only
> to argv[0], but to a concatenation of argv[0..argc].
>
> I am starting to think perl_parse() should be somewhat less magical...
>
> > #ps -eaf | grep httpd
> >
> > I normally get something like:
> > root 3634 1 0 20:31 ? 00:00:00 /app/apache/bin/httpd -k start
> > [...]
> >
> > But the fix gives only
> >
> > #ps -eaf | grep httpd
> >
> > root 3634 1 0 20:31 ? 00:00:00 /app/apache/bin/httpd
> > [...]
> >
> > without the arguments passed.
>
>
> --
> Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID :
> 88C3A5A5
> http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107
> 88C3A5A5
>
>
>

Re: [mp2] Directive changes the command nam

Posted by pradeep kumar <pr...@gmail.com>.
I want to know how i can get the position of the "-k start" as it can be at
any location. So assuming some position of it and hard coding it does not
help. Also I tried using 5.8.0 perl without the fix. It somehow did not
reproduce the problem. How is this happening. Since apache was not giving
the "-k start" to mod_perl how did 5.8.0 give the whole command line.

On 11/15/05, Philippe M. Chiasson <go...@ectoplasm.org> wrote:
>
> pradeep kumar wrote:
> > #diff src/modules/perl/modperl_config.c
> > src/modules/perl/modperl_config.c.org
> > 175c175
> > < modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p, server_rec
> *s)
> > ---
> >> modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p)
>
> In the future, diff -u is much more preferred (being more human readable)
>
> > > [...]
> > This however is not giving me the "-k start". How can I get that.
>
> You would have to add it yourself, as -k arguments are used by apache to
> start
> (or restart/shutdown) a running apache, so it will start an actual httpd
> process
> _without_ that command line argument.
>
>
> --------------------------------------------------------------------------------
> Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID :
> 88C3A5A5
> http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107
> 88C3A5A5
>
>
>

Re: [mp2] Directive changes the command nam

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
pradeep kumar wrote:
> #diff src/modules/perl/modperl_config.c
> src/modules/perl/modperl_config.c.org
> 175c175
> < modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p, server_rec *s)
> ---
>> modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p)

In the future, diff -u is much more preferred (being more human readable)

> > [...]
> This however is not giving me the "-k start". How can I get that.

You would have to add it yourself, as -k arguments are used by apache to start
(or restart/shutdown) a running apache, so it will start an actual httpd process
_without_ that command line argument.

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: [mp2] Directive changes the command nam

Posted by pradeep kumar <pr...@gmail.com>.
#diff src/modules/perl/modperl_config.c
src/modules/perl/modperl_config.c.org
175c175
< modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p, server_rec *s)
---
> modperl_config_srv_t *modperl_config_srv_new(apr_pool_t *p)
177,178d176
< int i=0,len=0;
< char *str1=NULL;
202,203c200,211
< /* make sure httpd's argv[0] is the first argument so $0 is
< * correctly connected to the real thing */
---
> /* must copy ap_server_argv0, because otherwise any read/write of
> * $0 corrupts process' argv[0] (visible with 'ps -ef' on most
> * unices). This is due to the logic of calculating PL_origalen in
> * perl_parse, which is later used in set_mg.c:Perl_magic_set() to
> * truncate the argv[0] setting. remember that argv[0] passed to
> * perl_parse() != process's real argv[0].
> *
> * as a copying side-effect, changing $0 now doesn't affect the
> * way the process is seen from the outside.
> */
> modperl_config_srv_argv_push(apr_pstrmemdup(p, ap_server_argv0,
> strlen(ap_server_argv0)));
205,217d212
< for(i=0;i<s->process->argc;i++)
< {
< len+=strlen(s->process->argv[i]);
< len++;
< }
< str1=(char *)malloc(len);
< for(i=0;i<s->process->argc;i++)
< {
< strcat(str1,s->process->argv[i]);
< strcat(str1," ");
< }
< modperl_config_srv_argv_push(str1);
266c261
< modperl_config_srv_t *scfg = modperl_config_srv_new(p, s);
---
> modperl_config_srv_t *scfg = modperl_config_srv_new(p);
317c312
< *mrg = modperl_config_srv_new(p, add->server);
---
> *mrg = modperl_config_srv_new(p);

Somehow the "-k start" which is given at the command line is not getting
reflected in argv. This goes missing from argv. So when I start apache as
#/app/apache/bin/httpd -d /app/apache -k start
#ps -eaf | grep www
www 20734 20724 0 12:59:55 ? 0:00 /app/apache/bin/httpd -d /app/apache
www 20733 20724 0 12:59:55 ? 0:00 /app/apache/bin/httpd -d /app/apache
root 20724 1 0 12:59:53 ? 0:01 /app/apache/bin/httpd -d /app/apache
www 20729 20724 0 12:59:54 ? 0:00 /app/apache/bin/httpd -d /app/apache
#/app/apache/bin/httpd -d /app/apache -k startssl
#ps -eaf | grep www
www 20734 20724 0 12:59:55 ? 0:00 /app/apache/bin/httpd -d /app/apache -D
SSL
www 20733 20724 0 12:59:55 ? 0:00 /app/apache/bin/httpd -d /app/apache -D
SSL
root 20724 1 0 12:59:53 ? 0:01 /app/apache/bin/httpd -d /app/apache -D SSL
www 20729 20724 0 12:59:54 ? 0:00 /app/apache/bin/httpd -d /app/apache -D
SSL

This however is not giving me the "-k start". How can I get that.

On 11/10/05, Philippe M. Chiasson <go...@ectoplasm.org> wrote:
>
> pradeep kumar wrote:
> > I tried to read the whole of argv and push it in
> > modperl_config_srv_argv_push(). But what I can get only upto
> > "/app/apache/bin/httpd -d /app/apache" and not the whole of
> > "/app/apache/bin/httpd -d /app/apache -k start". I tried to print
> > argv[3] which just gave me null. How can I get the rest of the
> arguments.
>
> Not sure I follow exactly what you are saying, but please, post whatever
> code you have, it's usually much better than trying to explain code (a
> diff
> would be great)
>
> But once again, like I said, we are being bitten by too much magic here,
> and
> especially on HP-UX, it might not even be possible to reset the process
> full
> command name + command arguments at all.
>
> --------------------------------------------------------------------------------
> Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID :
> 88C3A5A5
> http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107
> 88C3A5A5
>
>
>

Re: [mp2] Directive changes the command nam

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
pradeep kumar wrote:
> I tried to read the whole of  argv and push it in
> modperl_config_srv_argv_push(). But what I can get only upto
> "/app/apache/bin/httpd -d /app/apache" and not the whole of
> "/app/apache/bin/httpd  -d /app/apache -k start". I tried to print
> argv[3] which just gave me null. How can I get the rest of the arguments.

Not sure I follow exactly what you are saying, but please, post whatever
code you have, it's usually much better than trying to explain code (a diff
would be great)

But once again, like I said, we are being bitten by too much magic here, and
especially on HP-UX, it might not even be possible to reset the process full
command name + command arguments at all.
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5