编程学习网为您整理以下代码实例,主要实现:C语言库raise()函数,希望可以帮到各位朋友。
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
voID signal_catchfunc(int);
int main () {
int ret;
ret = signal(SIGINT, signal_catchfunc);
if( ret == SIG_ERR) {
printf("Error: unable to set signal handler.\n");
exit(0);
}
printf("Going to raise a signal\n");
ret = raise(SIGINT);
if( ret !=0 ) {
printf("Error: unable to raise SIGINT signal.\n");
exit(0);
}
printf("Exiting...\n");
return(0);
}
voID signal_catchfunc(int signal) {
printf("!! signal caught !!\n");
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!