Python – way to change effective process name in Python


Can I change effective process name of a Python script? I want to show a different name instead of the real name of the process when I get the system process list. In C I can set


But in Python

argv[0] = "othername"

doesn't seem to work. When i get process list (with ps ax in my linux box) the real name doesn't change. I prefer a portable solution (or else one solution for posix and another for windows environments), if it exists.

Thanks in advance

Best Solution

I've recently written a Python module to change the process title in a portable way: check

It is a wrapper around the code used by PostgreSQL to perform the title change. It is currently tested against Linux and Mac OS X: Windows (with limited functionality) and BSD portings are on the way.

Edit: as of July 2010, the module works with BSD and with limited functionality on Windows, and has been ported to Python 3.x.