photo
Jordan Sissel
geek

Sat, 06 Mar 2004

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 :)

Comments: 0 (view comments)
Tags:
Permalink: /geekery/105
posted at: 09:45

Search this site

Navigation

Metadata

Home About Resume My Code (SVN)

Articles

ARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work Efficiency

Projects

fex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scripts

Presentations

Yahoo! Hack Day '08 Yahoo! Hack Day '06 Unix Essentials Vi/Vim Essentials SSH Tunneling (Video)

Tag Cloud

Calendar

< March 2004 >
SuMoTuWeThFrSa
  1 2 3 4 5 6
7 8 910111213
14151617181920
21222324252627
28293031   

Friends

BarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler Shields

Technorati