[Melbourne-pm] $0 behaviour

Ben Hare benhare at gmail.com
Tue Jul 17 08:26:01 PDT 2012


Hey Mat and yes I'm still Perling..! :)

I like what Catalyst is doing regarding this. Maybe have a look at
that project if you haven't already.

NOTE: Below examples all relate to FastCGI implementations of Catalyst.

* Older versions made the script name show in top but not in ps ( ps
would just show 'perl', top would show 'script.cgi' ).
* The latest version does the reverse and will just show 'perl' in top
but in ps:

'perl-fcgi-pm [Xtapes]'

the [<app_name>] indicating each app's name as defined in Catalyst config.

I like this approach ( as long as the processes are running as
different users, you know what it is in top anyway ).

Some more ideas ( It's 00:55 and I'm too lazy to look at *how* they're
doing it sorry - exercise for reader :) ).

Ben.


On 16 July 2012 14:50, Mathew Robertson
<mathew.blair.robertson at gmail.com> wrote:
> Hi list,
>
> I having been having some quirky behaviour when assigning $0...
> For me this turned out to be as a result from this:
>
> $0 = abs_path(dirname($0))."/".basename($0);
>
> ie: make the process name (as shown in top/ps, be the name of the script -
> instead of the perl binary.
> Which worked well when running "pidof whatever.pl", "ps auxww | grep
> whatever.pl", but not so much for "killall whatever.pl".
>
> Some Googling has turned up the problem/cause:
> http://blogs.perl.org/users/aevar_arnfjor_bjarmason/2010/03/what-happens-when-you-assign-to-0.html
>
> perl version is: v5.14.2
>
>
> So I run the example shown -> which shows that the patch is applied.  Upon
> further investigation, I think the implementation could be refined, ie: in
> my code above, only the first 16 characters of string are chomped, thus
> leaving the program title with part of the the basepath of the script. In my
> case I worked around it using Sys::Prtcl->prctl_name($BASENAME),
>
>
> The suggested change to this enhancement would be, if $0 points at a script,
> then change $0 assignment so that Perl grok's the rightmost part of the
> path. ie: leave $0 as-is, but modify this patch as so.
>
> Thoughts?
> Mathew
>
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm



-- 
Ben Hare
Professional Web Development Services
ABN: 22-48-55-71-887
Phone: +61-415-607-197
Web: http://www.benhare.com
Email: ben at benhare.com


More information about the Melbourne-pm mailing list