In a C program I can write argv[0] and the new name shows up in a ps listing.
How can I do this in bash?
In a C program I can write argv[0] and the new name shows up in a ps listing.
How can I do this in bash?
You can do it when running a new program via exec -a <newname>
.
I will just add that this must be possible at runtime, at least in some environments. Assigning $0 in perl on linux does change what shows up in ps. I do not know how that is implemented, however. If I can find out, i'll update this.
edit: Based on how perl does it, it is non-trivial. I doubt there is any bask built in way at runtime but don't know for sure. You can see how perl does it here: http://www.google.com/codesearch/phl=en#ekN1pJ28BN4/mg.c&q=perl_magic_set%20%22$0%22&sa=N&cd=1&ct=rc&l=2785
I've had a chance to go through the source for bash and it does not look like there is any support for writing to argv[0].