僵尸进程

 1 #include <stdio.h>
 2 #include <unistd.h>
 3 #include <stdlib.h>
 4 
 5 
 6 int main()
 7 {
 8     /*fork一个子进程*/
 9     pid_t pid = fork();
10     if(pid>0){
11         printf("in parent process,sleep for one miniute...zZ...\n");
12         sleep(3);
13         printf("after sleeping, and exit!\n");
14     }
15     else if(pid == 0){
16         /*子进程退出,成为一个僵尸进程*/
17         printf("in child rocess,and exit!\n");
18         exit(0);
19     }
20     return 0;
21 }

 

posted @ 2019-08-02 12:58  TTTCoder  阅读(245)  评论(0编辑  收藏  举报