What happens when you assign to $0?
According to git log
I've submitted 33 patches to perl core, I just submitted another one which on Linux changes this:
Into this:
If this patch gets applied doing killall onion
on 5.14 will get you a dead process instead of onion: no process found
, the same goes for ps(1)
and top(1)
which read the legacy process name by default. Before this patch the behavior of $0 assignment on Linux hadn't changed since perl 4.000 came out.
According to perlvar:
'If the program has been given to perl via the switches -e or -E , $0 will contain the string "-e" .'
How come in the above onion-5.12.txt output the "perl" line doesn't read "perl -e"?
It contained -e just before I overwrote it. Here's what
$0
looks like on my Linux system before you modify it:Because the "perl" returned by "ps hc $$" has no relation to $0, which is the whole issue here. The legacy process name is "perl" because the name of the executable file is "perl". If he had put this in a script called foo.pl and executed it via "./foo.pl", the legacy process name would be "foo.pl".
Right. Sorry if that wasn't clear enough. Right now
$0
only affectsps h $$
on Linux, but we don't set the legacy process name read byps hc $$
. With this patch we'll do that.