通过查看getuid和geteuid确定用户id并没有变为0(root);
通过getppid为1,可以确定构造的子进程的父进程为init
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- pid_t pid;
- pid = fork();
- if(pid == 0){
- printf("the parentid is %d\n", getppid());
- pid = fork();
- if(pid == 0){
- sleep(2);
- printf("the parentid is %d,the userid is %d, the euid is %d\n", getppid(),getuid() ,geteuid() );
- exit(0);
- }
- exit(0);
- }
- printf("the original id is %d\n", getpid());
- sleep(3);
- return 0;
- }
阅读(485) | 评论(0) | 转发(0) |