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.

posted @ 2013-08-23 23:19  dorothychai  阅读(329)  评论(0编辑  收藏  举报