Hacking Linux Exposed

About
Authors
Contents
Reviews
Foreword
Purchase

Articles
Books
Sourcecode
Tools
Errata

Home

 


(view this code in a separate window)

#!/usr/bin/perl
#
# argvswitcher
#
# Example of how trivial it is for a process
# to change the name seen in ps and friends.
# Implemented in perl here, but any language
# can do it, just modify the argv[0] character
# array.
#
# Copyright 2002, Bri Hatch
#
# Released under the GPL.  See COPYING file
# for more information.


system "ps -ef | grep $$"
print "\nNow changing my process name\n\n";

# Change argv[0], which is available in $0 in perl.
$0 = 'Howdy!';

system "ps -ef | grep $$"

exit