- Código:
#include <stdio.h>
#include <string.h>
#define CHANGE "Novo-nome"
int main(int argc,char *argv[]){
fprintf(stdout, "Nome do processo: %s\n",argv[0]);
fprintf(stdout, "Aperte enter para mudar o nome do processo para: %s",CHANGE);
getchar();
strcpy(argv[0],CHANGE);
fprintf(stdout, "Nome do processo mudado!!!");
getchar();
}
sh-4.1$ ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
mmxm 1662 0.0 0.1 4640 1660 pts/0 S 12:10 0:00 /bin/sh
mmxm 1665 0.0 0.0 1668 240 pts/1 S+ 12:10 0:00 ./mudar
mmxm 1666 0.0 0.1 2760 1056 pts/0 R+ 12:10 0:00 ps u
Depois de apertar enter:
sh-4.1$ ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
mmxm 1662 0.0 0.1 4640 1800 pts/0 S 12:10 0:00 /bin/sh
mmxm 1665 0.0 0.0 1668 240 pts/1 S+ 12:10 0:00 Novo-nome
mmxm 1674 0.0 0.1 2760 1048 pts/0 R+ 12:11 0:00 ps u