什么PID,PPID,PGID,PGRPID
SID,
UID,EUID,GID,EGID,
这些信息都保存在PCB(进程控制块)的结构体STRUCT TASK_STRUCK中。
例码:
1 #include <stdio.h> 2 #include <unistd.h> 3 4 int main(int argc, char *argv[]) 5 { 6 int i; 7 printf("\tuid\tgid\teuid\tegid\n"); 8 printf("parent\t%d\t%d\t%d\t%d\n", getuid(), getgid(), geteuid(), getegid()) 9 ; 10 if(fork() == 0) 11 { 12 printf("child\t%d\t%d\t%d\t%d\n", getuid(), getgid(), geteuid(), getegid 13 ()); 14 } 15 printf("\t pid\t ppid \t pgid\n"); 16 printf("parent\t%d\t%d\t%d\n", getpid(), getppid(), getpgid(0)); 17 for(i = 0; i < 2; i++) 18 { 19 if(fork() == 0) 20 printf("child \t%d\t%d\t%d\n", getpid(), getppid(), getpgid(0)); 21 } 22 return 0; 23 }
时间: 2024-11-18 17:37:50