Search this site

Metadata

Articles

Projects

Presentations

Neat perl trick

I've never known how programs change what their command-lines are listed as in ps(1) output. I knew that $0 in perl would let you view what the program was called as, so I took the chance of trying to actually *set* this variable. Here's what happened:
whack(~) [530] !130! > perl -e 'sleep'&
[1] 89053
whack(~) [531] > ps | grep perl
89053  p3  SL     0:00.00 perl -e sleep
...
whack(~) [523] > perl -e '$0 = "Hello there!"; sleep' &
[1] 89119
whack(~) [524] > ps | grep perl
89119  p3  SL     0:00.00 Hello there! (perl)
Neat? I think so... You may not, whatever :)

0 responses to 'Neat perl trick'

Showing last 0 comments... (Click here to view all comments)


Leave a reply

You need javascript enabled to use this form. Anti-spam efforts ongoing. Also, if the comment doesn't show up, it's because the form expired. Go back and copy your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm just playing with antispam methods right now. If this insists on not working, please email me about it.

Name (required)
E-mail (optional, if you want me to be able to email you back)
URL (also optional)
Comment: