![](https://t1.daumcdn.net/tistory_admin/static/manage/images/r3/default_L.png)
|
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void signalHandler(int signo);
main()
{
/* SIGINT 시그널 받으면 signalHandler 실행하도록 설정 */
signal(SIGINT, signalHandler);
while(1) {
printf("Hello World\n");
sleep(1);
}
}
void signalHandler(int signo)
{
//SIGINT 시그널을 받으면 이함수가 소출되고 SIGINT의 넘버를 받은 signo를 출력하고
printf("Hi! signal %d\n", signo); /* signo는 시그널 번호를 출력을 해준다 */
/* SIGINT 시그널 받으면 시스템에서 기본적으로 설정한 동작을 하도록 설정
SIG_DFL이 실행 그다음 부터는 월래 대로 키를 입력하는대로 먹는다*/
signal(SIGINT, SIG_DFL);
}
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
main()
{
int count=0;
/* SIGINT 시그널 받으면 무시하도록 설정 */
signal(SIGINT, SIG_IGN);
while (1) {
printf("Hello World\n");
sleep(1);
if (++count == 5) /* count가 5가 되면 */
/* SIGINT 시그널 받으면 시스템에서 기본적으로 설정한 동작을 하도록 설정 */
signal(SIGINT, SIG_DFL);
}
}
5초가 지날때까지 콘트롤 제트가 먹지 않는다
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
main()
{
/* SIGINT 시그널 받으면 무시하도록 설정 */
signal(SIGINT, SIG_IGN);
while (1) {
printf("Hello World\n");
sleep(1); /* 1초 동안 정지 */
}
}
콘트롤 -Z 해서 스탑하고 나간당. 그리고 킬-9를 입력 킬한다.
sokoban's Blog is powered by Daum & Tattertools