When you type \"ps aux\" the ps command shows command arguments that the program was run with. Some programs change this as a way of indicating status. I\'ve tried changing
You had the right idea, but you don't change the pointers in argv[n]
, you must change the string pointed to by argv[0]
itself:
#include
#include
int main(int argc,char **argv)
{
size_t maxlen = strlen(argv[0]);
memset(argv[0], 0, maxlen);
strncat(argv[0], "Hi Mom!", maxlen);
pause();
return 0;
}
(Note that whether or not this actually changes the command name shown by ps
is system-dependent).