1: #include <stdlib.h>

   2: int system(const char *command);

   3:  

   4: while (something) {

   5:     int ret = system("foo");

   6:     if (WIFSIGNALED(ret) &&

   7:         (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))

   8:             break;

   9: }

 

宏定义

含义

WIFEXITED(status)

如果进程通过系统调用_exit或函数调用exit正常退出,该宏的值为真。

WIFSIGNALED(status)

如果子进程由于得到的信号(signal)没有被捕捉而导致退出时,该宏的值为真。

WIFSTOPPED(status)

如果子进程没有终止,但停止了并可以重新执行时,该宏返回真。这种情况仅出现在waitpid调用中使用了WUNTRACED选项。

WEXITSTATUS(status)

如果WIFEXITED(status)返回真,该宏返回由子进程调用_exit(status)或exit(status)时设置的调用参数status值。

WTERMSIG(status)

如果WIFSIGNALED(status)返回为真,该宏返回导致子进程退出的信号(signal)的值。

WSTOPSIG(status)

如果WIFSTOPPED(status)返回真,该宏返回导致子进程停止的信号(signal)值。

 

Termination Signals

int SIGINT

The SIGINT (“program interrupt”) signal is sent when the user types the INTR character (normally C-c). See Special Characters, for information about terminal driver support for C-c.

int SIGQUIT

The SIGQUIT signal is similar to SIGINT, except that it's controlled by a different key—the QUIT character, usually C-\—and produces a core dump when it terminates the process, just like a program error signal. You can think of this as a program error condition “detected” by the user.

System call in linux by C的更多相关文章

  1. 转 PHP中exec、system等函数调用linux命令问题

    PHP中exec.system等函数调用linux命令问题 先小说两句:今天研究了下PHP调用LINUX命令的功能,一开始怎么做都调用不成功,试了好久才终于成功了,所以发出来分享一下.下面我将详细介绍 ...

  2. [转帖]DotNetCore跨平台~System.DrawingCore部署Linux需要注意的

    DotNetCore跨平台~System.DrawingCore部署Linux需要注意的   https://www.bbsmax.com/A/QV5ZemYVJy/?tdsourcetag=s_pc ...

  3. DotNetCore跨平台~System.DrawingCore部署Linux需要注意的

    回到目录 你在windows上使用图像组件没有任务问题,但部署到linux之后,将注意以下几点: 安装nuget包ZKWeb.System.Drawing 项目里还是引用System.DrawingC ...

  4. c/c++中system函数在Linux和windows下区别

    windows 在windows下的system函数中命令可以不区别大小写! 功 能: 发出一个DOS命令 #include <stdlib.h> int system(char *com ...

  5. os.system('cmd')在linux和windows系统下返回值的差异

    今天,用os.system('cmd')分别在windows和linux平台上执行同一ping命令,命令执行失败时返回码不同,windows为1,而linux下返回为256,如下: linux下: & ...

  6. Linux出现Read-only file system错误的解决方法

    造成这个问题的解决办法大多数是由于非正常关机后导致文件系统受损引起的,在系统重新启动之后,受损分区就会被Linux自己主动挂载为仅仅读.解决办法是通过fsck来修复文件系统,然后重新启动就可以,下面是 ...

  7. linux flushing file system caches

    We may drop the file system caches on Linux to free up memory for applications. Kernels 2.6.16 and n ...

  8. System.Drawing Linux Centos7 The type initializer for 'Gdip' threw an exception

    System.Drawing 在linux使用时提示异常 The type initializer for 'Gdip' threw an exception 解决方案: yum install au ...

  9. Linux环境搭建-在虚拟机中安装Centos7.0

    最近在空闲时间学习Linux环境中各种服务的安装与配置,都属于入门级别的,这里把所有的学习过程记录下来,和大家一起分享. 我的电脑系统是win7,所以我需要在win7上安装一个虚拟机-VMware,然 ...

随机推荐

  1. Online Object Tracking: A Benchmark 论文笔记(转)

    转自:http://blog.csdn.net/lanbing510/article/details/40411877 有博主翻译了这篇论文:http://blog.csdn.net/roamer_n ...

  2. hrb 2134 素数

    分拆素数和 Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 176(99 users) Total Accepted: 106(93 u ...

  3. redhat 6 / centos 6 搭建Django环境

    1)首先 安装的时候  到 选择安装那些包的时候 把 编译环境和开发的包 那块全部打上勾 2)系统虽然自带Python安装包,但是版本比较低.所以推荐自行进行tar包编译安装比较新的 https:// ...

  4. 创建一个最简单的Linux随机启动服务

    转自: http://xiaoxia.org/2011/11/15/create-a-simple-linux-daemon/

  5. 【OpenStack】OpenStack系列8之Nova详解 Neutron详解

    Neutron下载安装 下载:git clone -b stable/icehouse https://github.com/openstack/neutron.git pip install -r ...

  6. Convert Sorted Array to Binary Search Tree With Minimal Height

    Given a sorted (increasing order) array, Convert it to create a binary tree with minimal height. Exa ...

  7. jQuery基础 - 改变CSS样式

    jQuery提供css()的方法来实现嵌入式改变元素样式,css()方法在使用上具有多样性.其中一种接受两个输入参数:样式属性和样式值,它们之间用逗号分开.比如我们要改变链接颜色,我们可以使用下面的代 ...

  8. GLSL

    变量修饰符 修饰符给出了变量的特殊含义,GLSL中有如下修饰符: ·const – 声明一个编译期常量. ·attribute– 随不同顶点变化的全局变量,由OpenGL应用程序传给顶点shader. ...

  9. java用代理访问

    Properties prop = System.getProperties(); prop.setProperty("http.proxyHost", "localho ...

  10. discuz 学习

    一.Discuz首页“今日”“昨日”“欢迎新会员”等文字删除添加 搜索templeta/default/forum/discuz.htm   (使用非默认模版的请修改当前使用模版的discuz.htm ...