设为首页 加入收藏

TOP

C/C++ on Liunx platform第三篇:process control
2014-11-24 00:33:08 来源: 作者: 【 】 浏览:21
Tags:C/C Liunx platform 第三篇 process control

趁着休息这两天,把基本的C linux API和标准库的内容发布下~~,作为一个记录,也提供给大家做参考,请多提comments。

Create process API定义在unistd.h中。
函数原型:
pid_t fork(void);
对子进程返回0,对父进程返回子进程pid.
如果父进程不处理子进程的exit status, 子进程就成为 Z process。
避免Z process:
1. 使用 pid_t waitpid(pid_t,int*,int);来阻塞等待子进程退出。
2. 父进程使用singal进行异步处理,当子进程结束时,发送SIGCHLD signal 给父进程,父进程收到SIGCHLD后再调用waitpid()。
关于信号的定义和操作见signal.h

摘自 leonzhang
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C/C++ on Liunx platform第二篇:.. 下一篇编码裁剪算法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: