wait()函数,作用:阻塞等待任意子进程,回收子进程8kb物理内存
来源:互联网 发布:gis软件开发工程师 编辑:程序博客网 时间:2024/05/17 02:15
#include<stdio.h>#include<stdlib.h>#include <unistd.h>//wait()函数//作用:阻塞等待任意子进程,回收子进程8kb物理内存int main(void){ printf("main process pid = %d\n",getpid()); pid_t pid; pid = fork();//创建子进程 if(pid < 0) { perror("fork error"); exit(1);//结束进程 } if(pid == 0) { printf("子进程pid = %d\n",getpid()); sleep(1); printf("********\n"); exit(1); } if(pid > 0) { printf("父进程pid = %d\n",getpid()); //阻塞等待任意子进程,回收子进程8kb物理内存 wait(NULL); printf("-------------\n"); exit(1); } return 0;}/*$ ./a.outmain process pid = 25446父进程pid = 25446子进程pid = 25447********-------------*/
阅读全文
0 0
- wait()函数,作用:阻塞等待任意子进程,回收子进程8kb物理内存
- 父进程wait回收子进程
- 信号注册函数回收子进程,waitpid非阻塞回收
- 让wait等待所有子进程结束
- 【Linux】回收子进程—wait/waitpid
- 进程学习5--父进程wait回收子进程
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- 父进程等待子进程结束 waitpid wait
- 父进程等待子进程终止 wait, WIFEXITED, WEXITSTATUS
- Linux退出进程exit/_exit和等待子进程退出wait函数分析
- 等待子进程结束
- 并查集趣解[转]
- 最常用的15大Eclipse开发快捷键技巧
- HTML5(三)
- 深入理解Java垃圾回收机制
- 3.常量指针、指针常量、指针数组、数组指针、指针函数、函数指针
- wait()函数,作用:阻塞等待任意子进程,回收子进程8kb物理内存
- 消除对泛型和泛型的限制
- Python学习日记 第四天
- 《TCP/IP详解 卷1》 笔记: TCP的交互数据流
- kubernetes的编译、打包
- LeetCode Integer to Roman
- Android 国际货币格式化的一个小知识点
- 分布式系统事务一致性解决方案
- 八周第一次课 2017.12.4 linux任务计划cron、chkconfig工具、systemd管理服务、unit介绍、target介绍