欢迎各位兄弟 发布技术文章
这里的技术是共享的
- 1 #include<stdio.h>
- 2 #include<stdlib.h>
- 3
- 4 int main()
- 5 {
- 6 pid_t id=fork();
- 7 if(id<0)
- 8 {
- 9 printf("error\n");
- 10 return 1;
- 11 }
- 12 else
- 13 {
- 14 if(id>0)//这里是父进程
- 15 {
- 16 printf("this is parent id=%d\n",getpid());
- 17 sleep(30);
- 18 }
- 19 else
- 20 {
- 21 printf("child become zombie id=%d\n",getpid());
- 22 sleep(5);
- 23 exit(EXIT_SUCCESS);
- 24 }
- 25 }
- 26
- 27 return 0;
- 28 }
- 29
来自 https://blog.csdn.net/Hanani_Jia/article/details/81841714