zoukankan      html  css  js  c++  java
  • System call in linux by C

       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.

  • 相关阅读:
    PHP header函数设置http报文头示例详解
    在Windows下为PHP安装redis扩展
    CMD模拟http请求
    strstr使用
    memset使用
    QT修改应用程序图标
    纪念下自学QT 第十天 终于写成了串口调试助手
    QT设置textEdit光标到末尾
    QT设置TextEdit颜色
    QT设置QToolBar带有图标和文字
  • 原文地址:https://www.cnblogs.com/dorothychai/p/3278787.html
Copyright © 2011-2022 走看看