3

Is it possible to programatically change an executable name (ucmd) of a unix process as reported by ps?

unix/POSIX way would be nice but Linux specific solution would suffice.

I want to change what is reported here

> ps -o ucmd    
CMD
zsh
ps

not this, this I know ;)

> ps -o command
COMMAND
zsh
ps -o command

thanks

P.S. Not trying to create a rootkit, its just that net-snmp looks at this name when checking processes and my program has a different name when called from init and directly from /etc/init.d (etc/rcX.d/SNNname instead of just name).

4

1 回答 1

6

您可以使用以下PR_SET_NAME功能执行此操作prctl()

prctl(PR_SET_NAME, (unsigned long)"xyzzy", 0, 0, 0);

但是,/etc/rcX.d/SNNname应该是启动进程的(指向 a 的符号链接)脚本,而不是指向进程可执行文件本身的链接。这也将解决问题。

于 2011-07-27T09:21:47.093 回答