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. xcode SVN

    Mac上SVN的管理工具: CornerStone http://blog.csdn.net/wohaoxuexi/article/details/8444184 步骤: 1. import 项目到s ...

  2. HDU2546(01背包饭卡)

    电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够).所以大家 ...

  3. RTX登录其他系统

    前台: <html> <head> <title>签名验证</title> <meta http-equiv="Content-Lang ...

  4. 【转】利用optimize、存储过程和系统表对mysql数据库表进行批量碎片清理释放表空间

    本文收集于本人的笔记本,由于找不到原文出处.在此省略,如哪位知道可以联系我加上. 核心是利用mysql系统表和“optimize table 表名”命令,对mysql数据表进行空间的释放.由于dele ...

  5. C标签判断两个值是否相等

    c标签判断两个值是否相等 Integer用:${user1.id eq user2.id}:int用:${user1.id == user2.id} 测试代码如下:<c:if test=&quo ...

  6. [MAC ] Mac-OSX下安装Git

    转载自 : http://www.cnblogs.com/shanyou/archive/2011/01/30/1948088.html Mac-OSX下安装Git是一件很简单的事,我们可以下载一个安 ...

  7. intellij 2016注册

    第一种方法: http://idea.qinxi1992.cn http://idea.imsxm.com/ http://107.191.37.186:11688

  8. Linux网络编程必看书籍推荐

    首先要说讲述计算机网络和TCP/IP的书很多. 先要学习网络知识才谈得上编程 讲述计算机网络的最经典的当属Andrew S.Tanenbaum的<计算机网络>第五版,这本书难易适中. &l ...

  9. mysql 数据库获取当前时间

    mysql> select now(); +---------------------+ | now() | +---------------------+ | 2016-05-27 17:34 ...

  10. Android常用查询网站

    一.老罗的Android之旅爱生活,爱Android http://blog.csdn.net/luoshengyang 二.Android中文API http://www.android-doc.c ...