#include<sys/types.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<errno.h>
#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<sys/stat.h>
#include<sys/wait.h>
#include<signal.h>
void sighandler(int);
int main()
{
signal(SIGINT, &sighandler);
while(1)
{
std::string cmd = "";
cmd = "clear";
system(cmd.c_str());
std::string cmd1 = "";
cmd1 = "date";
system(cmd1.c_str());
printf("\n");
printf("sleep 1 sec...\n");
sleep(1);
}
return 0;
}
void sighandler(int signum)
{
printf("messgae %d. jump:...\n", signum);
exit(EXIT_FAILURE);
}
SIGABRT (Signal Abort) 程序异常终止。
SIGFPE (Signal Floating-Point Exception) 算术运算出错,如除数为 0 或溢出(不一定是浮点运算)。
SIGILL (Signal Illegal Instruction) 非法函数映象,如非法指令,通常是由于代码中的某个变体或者尝试执行数据导致的。
SIGINT (Signal Interrupt) 中断信号,如 ctrl-C,通常由用户生成。
SIGSEGV (Signal Segmentation Violation) 非法访问存储器,如访问不存在的内存单元。
SIGTERM (Signal Terminate) 发送给本程序的终止请求信号。