I\'m on Linux and I am forking/execing a new process out of my C spawn application. Is it possible to also change the naming of these new child processes?
I want to
According to this comment, prctl(PR_SET_NAME)
only affects the "short name" of a thread. It has the same effect as writing into /proc/self/comm
.
To change the "long name" (/proc/self/cmdline
which is actually used by htop
and ps u
) you need some ugly hack (which is mentioned in that comment but the link is dead). An example of this kind of hack can be found in Chromium source code: https://cs.chromium.org/chromium/src/services/service_manager/embedder/set_process_title_linux.cc?sq=package:chromium&g=0