waitpid函数实例
2016-02-01 14:43
337 查看
#include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<sys/wait.h> #include<unistd.h> int main(void) { pid_t pc,pr; if((pc=fork())==-1) { printf("failed to create a new process\n"); exit(0); } else if(pc==0) { sleep(10); exit(0); } do { pr=waitpid(pc,NULL,WNOHANG); if(pr==0) { printf("No child exited\n"); sleep(1); } }while(pr==0); if(pr==pc) { printf("successfully get child %d\n",pr); } else { printf("some error occured\n"); } return 0; }
相关文章推荐
- ug-Assertion failure in [MyClass layoutSublayersOfLayer:]
- 剪发 Haircut
- hdoj--1151--Air Raid(最大独立集)
- hdoj--1151--Air Raid(最大独立集)
- Starting httpd: httpd: apr_sockaddr_info_get() failed
- 【转】UltraISO制作U盘启动盘安装Win7/9/10系统攻略
- 【Xamain 跨平台机制原理剖析】
- tools:context=".MainActivity的作用
- rails s 命令不起作用
- 出现( linker command failed with exit code 1)错误总结
- [INS-41112] Specified network interface doesnt maintain connectivi
- Rails 使用 Google Analytics 示例
- [Regular Expressions] Find Plain Text Patterns
- A*启发式搜索算法详解 人工智能
- the usage of activity_main.xml
- 获取sina,baidu,google财经历史和实时股票数据接口
- Aircrack-ng——Tutorial
- Airodump-ng——Description
- kali 2.0 — aircrack-ng dictionary — wordlists
- airbase-ng stops working after a while--wifi热点只能连接20秒左右