fork wait
2016-07-18 14:41
155 查看
如果父进程先结束,子进程不会自己结束
#include<stdio.h> #include<stdlib.h> #include<sys/wait.h> int main(){ int a,b,c; if(a = fork()){ printf("fork1---%ld\n",a); int stat; //等待子进程结束 pid_t child_pid = wait(&stat); if(WIFEXITED(stat)){ printf("exited with code %d\n",WEXITSTATUS(stat)); } }else{ printf("I'm child\n"); } //int stat; //pid_t child_pid = wait(&stat); //if(WIFEXITED(stat)){ // printf("exited with code %d\n",WEXITSTATUS(stat)); //} return 0; }
相关文章推荐
- hdu 1532 Drainage Ditches(最大流模板题)
- Syntax error, annotations are only available if source level is 1.5 or greater解决方法
- HDU-1021 Fibonacci Again
- HDU 1839 Delay Constrained Maximum Capacity Path(最短路+二分)
- Ubuntu 14中,Foxmail关联163邮箱账号时,总提示“密码错误”的解决方案
- Ain_EditPlus配置安装教程
- mac下Genymotion添加虚拟设备提示 The file is corrupt. Do you want to download the file again?解决方法
- 算法实战(三)--求K-Pairs
- main函数的两个参数
- Greenplum failed segment的恢复方法
- 从零开始,5分钟创建并玩转属于自己的区块链(图文攻略)
- 真机测试遇到 ——is not paired with your computer
- git时认证失败(Authentication failed )的解决
- 安装Ubutun 12.04 遇到the grub-efi-amd64-signed package failed to install into...【解决办法】
- 最新中国菜刀caidao-20160620下载和说明
- 【poj3691-DNA repair】AC自动机+DP
- ubuntu enable all Ubuntu software (main universe restricted multiverse) repositories use
- 8A - Train and Peter
- the user operation is waiting
- Gradle sync failed: Cause: org/gradle/api/publication/maven/internal/DefaultMavenFactory