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.

  • 相关阅读:
    hp一體機cartridge error及carriage jam4/22
    指纹仪zkonline.ocx:access violation...4/13
    IIS6:Service Unaviable 9/27
    寶寶的成長腳印3/15
    vs2003不能调试4/8
    C++ 的复制构造函数
    导入与导出数据 大容量复制程序(bcp)
    关于SQlserver数据库的加密应用
    DataGridView使用技巧
    使用C# 向记事本窗口发送消息
  • 原文地址:https://www.cnblogs.com/dorothychai/p/3278787.html
Copyright © 2011-2022 走看看