I would like to change name of main process, or probably main thread, in Rust. For example, if I have a tool foo and run it from shell
/usr/local/bin/foo --arg1 --arg2=qwe in process viewers I will see that whole command line. What I need is to change the command line viewed to say
foo is running.
For example, in Perl that can be achieved changing
$0 = "foor is running".
Some items I discovered so far.
- All command line arguments can be read with
std::env::args()but those are read-only values and I think I cannot change the first most argument with
- There is a crate
prctlbut it’s is not portable and works only on Linux. At least on Darwin it does not compile from the box.
- When constructing a new thread with
thread::Builderit’s possible to set it’s name but that is only for new threads and I cannot change the name of already running thread.
Could anybody point me to any portable solution which can help me please? Or maybe where to dig deeper?