WIFEXITED/WEXITSTATUS/WIFSIGNALED
WIFEXITED/WEXITSTATUS/WIFSIGNALED
If the exit status value (*note Program Termination::) of the child
process is zero, then the status value reported by `waitpid' or `wait'
is also zero. You can test for other kinds of information encoded in
the returned status value using the following macros. These macros are
defined in the header file `sys/wait.h'.
-- Macro: int WIFEXITED (int STATUS)
This macro returns a nonzero value if the child process terminated
normally with `exit' or `_exit'.
-- Macro: int WEXITSTATUS (int STATUS)
If `WIFEXITED' is true of STATUS, this macro returns the low-order
8 bits of the exit status value from the child process. *Note
Exit Status::.
-- Macro: int WIFSIGNALED (int STATUS)
This macro returns a nonzero value if the child process terminated
because it received a signal that was not handled. *Note Signal
Handling::.
子进程的结束状态返回后存于status,底下有几个宏可判别结束情况
WIFEXITED(status)如果子进程正常结束则为非0值。
WEXITSTATUS(status)取得子进程exit()返回的结束代码,一般会先用WIFEXITED 来判断是否正常结束才能使用此宏。
WIFSIGNALED(status)如果子进程是因为信号而结束则此宏值为真
WTERMSIG(status)取得子进程因信号而中止的信号代码,一般会先用WIFSIGNALED 来判断后才使用此宏。
WIFSTOPPED(status)如果子进程处于暂停执行情况则此宏值为真。一般只有使用WUNTRACED 时才会有此情况。
WSTOPSIG(status)取得引发子进程暂停的信号代码,
http://blog.chinaunix.net/uid-10554711-id-2948333.html
WIFEXITED/WEXITSTATUS/WIFSIGNALED的更多相关文章
- WIFEXITED WEXITSTATUS WIFSIGNALED(转)
wait的函数原型是: #include #include pid_t wait(int *status) 进 程一旦调用了wait,就立即阻塞自己,由wait自动分析是否当前进程的某个子进程已经退出 ...
- C++ wait捕捉的信号处理WIFEXITED/WEXITSTATUS/WIFSIGNALED
当一个进程正常或异常终止的时候,内核就像其父进程发送SIGCHLD信号,因为子进程是个异步事件,所以这种信号也是内核给那个父进程发的异步通知.父进程可以选择忽略该信号,或者提供一个该信号发生时即被调用 ...
- wait, WIFEXITED, WEXITSTATUS
wait, WIFEXITED, WEXITSTATUS 偶尔翻到了这几个关键字,找到个文章复习了下:“点我”.记录下: wait的函数原型是: #include <sys/types. ...
- 【转】linux : waitpid函数
原文网址:http://blog.csdn.net/jifengszf/article/details/3067841 [waitpid系统调用] 功能描述: 等待进程改变其状态.所有下面 ...
- wait函数返回值总结
之前在学习wait和waitpid函数的时候,就对使用宏WIFEXITED来检查获取的进程终止状态产生过疑惑:一般我们在程序中是调用的exit或者_exit函数来退出的,那么wait和waitpid函 ...
- (49)LINUX应用编程和网络编程之四 Linux进程全解
补充: 1. C程序的执行过程: C编译器调用链接器,链接器设置可执行程序文件的启动起始地址(启动例程),启动例程获得内核传递来的 命令行参数和环境变量值,为调用main函数做准备.[实际上该启动例 ...
- Linux-父进程wait回收子进程
1.wait工作原理 (1).子进程结束时,系统向其父进程发送SIGCHILD信号 (2).父进程调用wait函数后阻塞 (3).父进程被SIGCHILD信号唤醒然后去回收僵尸子进程 (4).父子进程 ...
- Android反调试笔记
1)代码执行时间检测 通过取系统时间,检测关键代码执行耗时,检测单步调试,类似函数有:time,gettimeofday,clock_gettime. 也可以直接使用汇编指令RDTSC读取,但测试AR ...
- CSAPP 之 ShellLab 详解
前言 本篇博客将会详细介绍 CSAPP 之 ShellLab 的完成过程,实现一个简易(lou)的 shell.tsh 拥有以下功能: 可以执行外部程序 支持四个内建命令,名称和功能为: quit:退 ...
随机推荐
- aop 注解 开启spring自带的事务
一些基本知识 可以 http://jinnianshilongnian.iteye.com/blog/1415606 serviceImpl.java package cn.us.service.im ...
- iOS - 跑马灯、弹幕
1.跑马灯 具体实现代码见 GitHub 源码 QExtension QMarqueeView.h #pragma mark - QMarqueeViewDelegate /// 跑马灯内容点击处理协 ...
- Android事件分发机制源代码分析
小小感慨一下,做android有一段时间了,一直以来都是习惯整理笔记存到有道笔记上,没有写博客的习惯. 以后逐步分类整理出来,也算"复习"一遍了 - _ - . android的事 ...
- python标准库介绍——25 errno 模块详解
==errno 模块== ``errno`` 模块定义了许多的符号错误码, 比如 ``ENOENT`` ("没有该目录入口") 以及 ``EPERM`` ("权限被拒绝& ...
- Socket tips: 同意socket发送UDP Broadcast
假设创建一个UDP Socket: socketHandle = socket(serverAddr->ai_family, serverAddr->ai_socktype, server ...
- android获取对话框文本注意事项
1.View注意设置成final类型如final View layout=.. . 2.获取文本框对象时候格式EditText e = (EditText)layout.findViewById(R. ...
- Meta Blogging
Meta Blogging 由来 偶然想到说如果哪一天cnblogs挂了,那之前记录的随笔怎么办?可不可以把它们给download下来本地保存一份.正好看到有个库叫requests, 干嘛不试试看呢. ...
- 玩转oracle学习第七天
1.上节回想 2.PL/SQL的进阶 3.oracle的视图 4.oracle的触发器 目标: 1.掌握PL/SQL的高级使用方法(能编写分页过程模块,下订单过程模块.. . ) 2.会处理or ...
- hdu 1532 最大流
#include <cstdio> #include <iostream> #include <algorithm> #include <queue> ...
- How it works: Linux audio explained
from: tuxradar.com/content/how-it-works-linux-audio-explained How it works: Linux audio explained Po ...