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
strcpy(argv[0],"othername");
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
I've recently written a Python module to change the process title in a portable way: check https://github.com/dvarrazzo/py-setproctitle
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.