#include <stdio.h>
#include <signal.h>
#define INPUTLEN 100
main()
{
struct sigaction newhandler; // 시그 액션 선언
sigset_t blocked;
void inthandler();
char x[INPUTLEN];
newhandler.sa_handler = inthandler; // 시그 액션을 핸들링할 함수를 정함
newhandler.sa_flags = SA_RESETHAND | SA_RESTART; // 옵션.. 한번만처리,
sigemptyset(&blocked);
sigaddset(&blocked, SIGQUIT);
newhandler.sa_mask = blocked;
if (sigaction(SIGINT, &newhandler, NULL) == -1)
perror("sig act ion");
else
while(1)
{
fgets(x, INPUTLEN, stdin);
printf("input : %s",x);
}
}
void inthandler(int s)
{
printf("call %d\n",s);
sleep(s);
printf("done %d\n",s);
}
'IT' 카테고리의 다른 글
bounced1d.c (0) | 2014.11.05 |
---|---|
sigactdemo2.c (0) | 2014.11.05 |
sigdemo3.c (0) | 2014.11.05 |
20141029 시스템 프로그래밍. curses. (0) | 2014.10.29 |
시스템 프로그래밍 중간고사 (0) | 2014.10.29 |