I\'m on Linux and I am forking/execing a new process out of my C spawn application. Is it possible to also change the naming of these new child processes?
I want to
The below code sample would change the name of the process to "Testing".
#include
#include
#include
int main (int argc, char *argv[]) {
char* temp = (char*) malloc (20);
strcpy(temp, "Testing");
temp[7] = 0;
printf("Argv[0] --> %s\n", argv[0]);
argv[0] = temp;
printf("Argv[0] --> %s\n", argv[0]);
return 0;
}
The output of above program is:
./a.out
Argv[0] --> ./a.out
Argv[0] --> Testing
The argv[0] contains the name of the process.