Question about argv[]
I am currently working on a c/c++ program that uses several child proccess (forks). The issue is I would like to see these listed by ps by the name, not by the parent name.
It was suggested that I overwrite argv[0] on the child. While this looks like it can work (tested a little) I just have a couple questions before I feel that this is safe coding.
1. Storage. How is argv stored (structure). I suspect there is a char* and a int for length. When I tested the code it looked like 'ps' still dumped the full length of the origional argv[0].
2. Is this a 'good thing' to do ? If there are any violations by messing with this please let me know, and why if you can.
Many Thanks.
example ps:
UID PID PPID C STIME TTY TIME CMD
mrx 28207 28186 0 18:44 pts/0 00:00:00 xterm
mrx 28226 28209 0 18:44 pts/1 00:00:00 ./bridgekeeper
mrx 28228 28226 0 18:44 pts/1 00:00:00 bk_thread er
mrx 28229 28186 0 18:44 pts/0 00:00:00 ps -af
(please note the extra "er" at end of test
|