简体   繁体   中英

How do I rename a process on Linux?

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.

似乎是你在寻找...

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.

如果使用subprocess.Popen而不是os.system,则可以使用executable参数指定要执行的实际文件的路径,并将要显示的名称作为参数args列表中的第一项传递。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM