3

I'm using Python, for what it's worth, but will accept answers in any applicable language.

I've tried writing to /proc/$pid/cmdline, but that's a readonly file.

I've tried assigning a new string to sys.argv[0], but that has no perceptible impact.

Are there any other possibilities? My program is executing processes via os.system (equivalent to system(3)) so a general, *NIX-based solution using an additional spawning process would be fine.

jemfinch
  • 2,851
  • 19
  • 24
  • 3
    Just curious, why would you *want* to? :) – Justin Ethier May 25 '10 at 19:31
  • 1
    possible duplicate of [Is there a way to change effective process name in Python?](http://stackoverflow.com/questions/564695/is-there-a-way-to-change-effective-process-name-in-python) – Daniel DiPaolo May 25 '10 at 19:39
  • 1
    Responding to Justin: It is common practice in unix servers such as apache and postgres to rewrite a generic process name with a short description of what the process is doing. This helps system admins (and desktop users) to see what's going on when they look at the system process list. – ʇsәɹoɈ May 25 '10 at 22:06

2 Answers2

0

Writing to *argv will change it, but you'll need to do that from C or the like; I don't think Python is going to readily give you access to that memory directly.

I'd also recommend just leaving it alone.

retracile
  • 12,167
  • 4
  • 35
  • 42
0

If you use subprocess.Popen instead of os.system you can use the executable argument to specify the path to the actual file to execute, and pass the name you want to show as the first item in the list that is parameter args.