ANNOUNCE: proctitle - manipulate 'argv[]' (process listing) of the Python process

Dave Cinege dcinege at psychosis.com
Mon Jul 22 20:00:55 EDT 2002


keyphrases:
setproctitle proctitle
change process name
change process title
change ps output 
argv[0] argv[-1]

It was about a year ago, I produced a nasty patch to sys that allowed
changing the raw argv[] of the python process. 

A year later its sad this functionality has *still* not be intergrated
into Python itself.  : <

In linux this modules allows one to change the output seen from 'ps'.
(And the processes 'cmdline' in /proc/)
It is useful for hiding 'python', an argument that is a password,
or update process information.

The joy of unempoyment has given me the time to rewrite my patch as
a stand alone module. The module is by no means done. I need people
to test on platforms other then Linux and provides results.

Once it has been made portable, I intend to talk to Guido about how
he'd like to see this intergrated into Python, and then do so.
It would likely become an extension to the posix module.

Please DL from:
	http://ftp.psychosis.com/python/
	ftp://ftp.psychosis.com/python/


An idea how it currently works:

	import proctitle
	Argv = proctitle.ProcTitle()

	print 'Saving Original argv[]'
	Argv.save()
	print 'argv[0:2]: ', Argv[0:2]
	print Argv

	Argv[0] = 'Python - Why use anything else?'
	Argv[0:] = 'Python - Why use anything else?'

	print 'Slide argv args back one. (hide "python")'
	print 'Process line now matches sys.argv'
	Argv[0:] = string.join(Argv[1:]).replace(',','')

	print 'Restoring Original argv[]'
	Argv.restore()






More information about the Python-list mailing list