1.wait

NAMEwait, waitpid, waitid - wait for process to change stateSYNOPSIS#include <sys/types.h>#include <sys/wait.h>pid_t wait(int *status);

父进程一旦调用了wait就立即阻塞自己,由wait自动分析是否当前进程的某个子进程已经退出,如果让它找到了这样一个已经变成僵尸的子进程,wait就会收集这个子进程的信息,并把它彻底销毁后返回;如果没有找到这样一个子进程,wait就会一直阻塞在这里,直到有一个出现为止
简而言之 就是死等 一定是阻塞的, 不能等待一个特定的进程
子进程的状态保存在一个int 的status的变量中,返回子进程的id号

2.waitpid

pid_t waitpid(pid_t pid, int *status, int options);
The value of pid can be:< -1   meaning  wait  for  any  child  process whose process group ID is equal to the  absolute value of pid.-1     meaning wait for any child process.0      meaning wait for any child process whoseprocess group ID is equal to that  of  the calling process.> 0    meaning wait for the child whose process ID is equal to the value of pid.
The value of options is an OR of zero
or more of the following constants:WNOHANG     return immediately if no child has exited.WUNTRACED   also  return if a child has stopped
(but not traced via ptrace(2)).
Status for traced children which have  stopped  is  provided even  if  this option is not specified.WCONTINUED (since Linux 2.6.10)also return if a stopped child has been resumed bydelivery of SIGCONT.

waitpid可以是非阻塞的,设置option

wait和waitpid相关推荐

  1. Linux wait() 和 waitpid()函数介绍

    转载自http://blog.csdn.net/wallwind/article/details/6998602 当一个进程正常或异常终止的时候,内核就像其父进程发送SIGCHLD信号,因为子进程是个 ...

  2. Linux环境编程--waitpid与fork与execlp

    waitpid waitpid(等待子进程中断或结束) 表头文件 #include<sys/types.h> #include<sys/wait.h> 定义函数 pid_t w ...

  3. Linux环境编程--linux中的perror、exit、_exit、wait 和 waitpid

    perror: #include<stdio.h>        #include<stdlib.h> 定义函数 void perror(const char *s);  pe ...

  4. linux 进程等待 wait 、 waitpid

    waitpid() 与 wait() 功能相似,都是用户主进程等待子进程结束或中断. 可用于进程之间的同步 wait 函数原型 pid_t wait(int *status); 函数说明 wait() ...

  5. 【转】linux中waitpid及wait的用法

    原文网址:http://www.2cto.com/os/201203/124851.html wait(等待子进程中断或结束) 表头文件 #include<sys/types.h> #in ...

  6. 8.6 wait和waitpid函数-进程控制

    8.6 wait和waitpid函数-进程控制 当一个进程正常或异常终止时,内核就向其父进程发送SIGCHLD信号.因为子进程终止是个异步事件(这可以在父进程运行的任何时候发生),所以这种信号也是内核 ...

  7. 详解wait和waitpid函数

    #include <sys/types.h> /* 提供类型pid_t的定义 */ #include <sys/wait.h> pid_t wait(int *status) ...

  8. linux中wait与waitpid的差别

    zombie不占用内存也不占用CPU,表面上我们可以不用在乎它们的存在,然而事实上UNIX系统限制了某一时刻能同时存在的进程的最大数目.如果程序不及时清理系统中的zombie,最终会导致进程数过多,当 ...

  9. 7.wait和waitpid

    wait和waitpid:当一个进程正常或者异常终止的时候,内核就会向其父进程发送SIGCHLD信号,用于父进程来接受子进程的终止状态. #include<sys/wait.h>pid_t ...

  10. UNIX高级环境编程(9)进程控制(Process Control)- fork,vfork,僵尸进程,wait和waitpid...

    本章包含内容有: 创建新进程 程序执行(program execution) 进程终止(process termination) 进程的各种ID 1 进程标识符(Process Identifiers ...

最新文章

  1. 祝贺自己itpub和csdn双双荣获专家博客标题
  2. crontab中运行python程序出错,提示ImportError: No module named解决全过程
  3. PHP提交表单到当前页动作检测
  4. java akka_AKKA文档(java版)——什么是AKKA?
  5. 关于TCHAR和string对象的c.str()一些注意事项
  6. hdu 3926 hands in hands
  7. JSP程序设计实训(五)——JSP基本语法(一)
  8. DVD-R、DVD+R以及DVD-RW和DVD+RW的功能区别
  9. 安卓逆向学习 之 KGB Messenger的writeup(1)
  10. 计算机开模拟器,低配电脑如何强制开50个安卓模拟器挂机
  11. 工作总结:简明扼要,突出重点
  12. 解决WIN10打开XBOX闪退问题(2022)
  13. iOS 常用框架介绍
  14. excel切片器_用Excel切片器做自动化表格,动态呈现,瞬间高大上
  15. Activiti7实战二:实现具有拒签功能的请假2层审批流程
  16. html空间进入动画界面,HTML5 / CSS3 Transform / Animation 示例页面
  17. 知乎里怎么看个人简介_怎么写简历中的自我评价?
  18. 开始记录深度学习工作站的学习之路
  19. nodejs tar 打包脚本,打包压缩文件文件夹
  20. 从今天开始给自己定一个小目标

热门文章

  1. jquery 多个class操作
  2. nginx 配置虚拟机实例
  3. linux 删除文件内容
  4. 秒杀系统的核心点都在这里,快来取
  5. SQL Server 2012 自动增长列,值跳跃问题
  6. Could not load the defaultimg image referenced from a nib in the bundle with identifier com.abc
  7. UITableViewCell 添加 checkbox 多选
  8. 3001.Linux维护和管理培训.实操考核A
  9. 如何在 Windows Server 2003 中配置权威时间服务器
  10. 部署jar包项目到服务器上