I'm currently trying to change the process name of a process so I can read the more easily with htop, top, .... I want to LD_PRELOAD
this code into another process so it gets renamed by an environemt variable.
I found a lot of stuff in the internet, but nothing works:
prctl(PR_SET_NAME, "Test");
This does not work because htop is not honoring the name.
Nginx setproctitle
(Link) doesn't work as well, because it strips the parameters (which are needed by the process).
I tried everything I found and now I'm out of ideas.
Is this even possible in linux? And how?
The ps -p <PID> command is pretty straightforward to get the process information of a PID. Alternatively, we can also access the special /proc/PID directory to retrieve process information.
The process identifier (process ID or PID) is a number used by Linux or Unix operating system kernels. It is used to identify an active process uniquely.
The name for a new process can be set via the “name” argument in the constructor to the multiprocessing. Process class when creating a new process.
Just run your program by shell script or your program through exec
and pass desired name as argv[0]
:
#/bin/bash
exec -a fancy_name a.out ...
or C/C++:
execl( "./a.out", "fancy_name", ... );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With