修改通过fork生成的进程名

#include <sys/prctl.h>

int main(char argc[],int argv)
{
        unsigned int i = 0;
        unsigned int pid1,pid2;

        if(0 == fork()){
                prctl(PR_SET_NAME,"Child",NULL,NULL,NULL);
		for(;;){
                	for(i=0;i<100000;i++);
                	pid1= getpid;
                	printf("This is the child process,process id is %d",pid1);
		}
        }else{	
		prctl(PR_SET_NAME,"Child",NULL,NULL,NULL);
		for(;;){
			for(i=0;i<100000;i++);
                	pid1= getpid;
                	printf("This is the child process,process id is %d",pid1);
		}
	}
   	return 0;
}

你可能感兴趣的:(修改通过fork生成的进程名)