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.

  • 相关阅读:
    C#关于HttpClient的应用(二):融云IM集成
    C#关于HttpClient的应用(一):获取IP所在的地理位置信息
    PHP逐字符读取数据
    PHP逐行读取数据
    PHP函数的创建
    PHP数组的创建
    PHP基础学习代码案例
    查看端口号占用情况
    apache错误 Unable to open process" with PID 4!
    NUnit TestFixtureSetup 和 TestFixtureTearDown
  • 原文地址:https://www.cnblogs.com/dorothychai/p/3278787.html
Copyright © 2011-2022 走看看