Philippe M. Chiasson wrote:
I've finally had time to dig deeper in the troubling $0 and process display
problems that seem to exist at least on *BSDs and HP-UX.

On linux, modifications to the original argv[0] will directy modify the process
information. On some other OSes, some special API is needed.

Perl's $0 magic handling correctly handles these OS differences and just does
the right thing.

So, simply passing Perl a _copy_ of argv[0] does disable $0 magic on Linux, but
not on the other OSes where it just calls the correct API (setproctitle() on 
BSDs)

On top of that, calling perl_parse() as is commonly done for embedders with
an argument of -e0, results in an initial $0 of '-e'. And that's what
is hapenning to pradeep.

But that's not all ;-) ap_server_argv0 _is_ _not_ httpd' argv[0], it's argv[0]
skipped forward to remove path components and leave only the binary's name
(httpd). The correct way to get at the real argv[0] is in server->proc->argv

All this combined has led to a more than troubling bug.

The correct solution (see patch) is:

 - Reset $0 to the _real_ argv[0] after calling perl_parse()
    /* Also need to fix PL_origalen */
    PL_origalen = strlen(argv[0])+1;
    /* argv[0] = '/usr/bin/httpd' */
    sv_setpv_mg(get_sv("0",0), argv[0]);

 - Use the real argv[0] (s->process->argv) and not a copy

Dear God!

+1

The test suite passes 100% with this applied and manual inspection of ps looks good.

That on FreeBSD... hopefully I'll have some Open/Net BSD in the near future too.


--
END
------------------------------------------------------------
    What doesn't kill us can only make us stronger.
                Nothing is impossible.
                                
Philip M. Gollucci ([EMAIL PROTECTED]) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
  http://www.liquidityservicesinc.com
       http://www.liquidation.com
       http://www.uksurplus.com
       http://www.govliquidation.com
       http://www.gowholesale.com

Reply via email to