首页 > 系统服务 > 详细

进程参考代码

时间:2016-07-21 18:02:00      阅读:185      评论:0      收藏:0      [点我收藏+]
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <sys/types.h>
 4 #include <unistd.h>
 5 #include <pwd.h>
 6 #include <sys/wait.h>
 7 
 8 int main(void)
 9 {
10     pid_t pid = fork();
11     int status;
12     if(pid== -1)
13     {
14         printf("fork failed\n");
15         return 0;
16     }
17     if(pid==0)
18     {
19         exit(0);
20     }
21     else
22     {
23         printf("parent process start\n");
24         wait(&status);
25         sleep(100);
26 //        printf("status =%d\n",WEXITSTATUS(status));
27         printf("parent process end\n");
28         return 0;
29     }
30 
31     return 0;
32 }

 

进程参考代码

原文:http://www.cnblogs.com/leejxyz/p/5692461.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!