#include <stdio.h>
#include <signal.h>
#define INPUTLEN 100
main(int ac, char *av[])
{
void inthandler(int);
void quithandler(int);
char input[INPUTLEN];
int nchars;
signal (SIGINT, inthandler);
signal(SIGQUIT, quithandler);
do{
printf("\ntype msg\n");
nchars = read(0, input, (INPUTLEN-1));
if (nchars == -1)
perror("read return error");
else
{
input[nchars] = '\0';
printf("typed : %s", input);
}
}while(strncmp(input,"quit",4)!=0);
}
void inthandler(int s)
{
printf("receive signal %d........ waiting\n",s);
sleep(2);
printf("leaving inthandler......\n");
}
void quithandler(int s)
{
printf("receive signal %d...... waiting.......\n",s);
sleep(3);
printf("lesving quithandler\n");
}
'IT' 카테고리의 다른 글
sigactdemo2.c (0) | 2014.11.05 |
---|---|
sigactdemo.c (0) | 2014.11.05 |
20141029 시스템 프로그래밍. curses. (0) | 2014.10.29 |
시스템 프로그래밍 중간고사 (0) | 2014.10.29 |
canonical (0) | 2014.10.19 |