Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C 言語でプログラムのプロセス名を変更する必要があります。 正確には、これは私が変更したいスレッドの名前ではありません。 プログラムの名前を変更したいのですが、私が見つけた唯一の解決策は、の値を変更することですargv[0]。 で別の解決策も見つけましprctl(PR_SET_NAME, "newname")たが、この解決策は機能しません。
argv[0]
prctl(PR_SET_NAME, "newname")
prctl呼び出しと変更の違いは次のargv[0]とおりです。
prctl
/proc/$pid/cmdline
prctl(PR_SET_NAME)
/proc/$pid/status
つまり、 と を発行ps -aしているプロセスの名前が異なりますps -ax。
ps -a
ps -ax
ps の実行中に異なる引数に同じプロセス名が必要な場合は、両方を実行できます (つまり、 changeargv[0]と invoke prctl)。
答えが役立つことを願っています。