views:

150

answers:

4

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.

A: 

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
+2  A: 

This seems to be what you are looking for...

ivans
On a related note... I've never actually tried to do this in Python myself, but it looks fugly :-(
ivans
A: 

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.

Andrew E. Falcon
A: 

Perl allows this (so long as the operating system allows it) by changing the variable $0.

mobrule