19 lines
316 B
C
19 lines
316 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <signal.h>
|
||
|
|
||
|
int catch(int sign);
|
||
|
|
||
|
int main(void){
|
||
|
signal(SIGINT, catch);//将信号与catch函数关联
|
||
|
printf("lingzhaohui \n");
|
||
|
sleep(10);
|
||
|
printf("end\n");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int catch(int sign){
|
||
|
printf("\nyou pressed 'ctrl+c'\n");
|
||
|
return 1;
|
||
|
}
|