/*------------------------------------------------------------------------------------ ÆÄÀϸí : signal_test.c ±â ´É : signal() ½Ã½ºÅÛ ÄÝ »ç¿ë ¿¬½À ÄÄÆÄÀÏ : cc -o signal_test signal_test.c ½ÇÇ࿹ : signal_test ------------------------------------------------------------------------------------*/ #include #include #include #include int my_signal(); /* »õ·Î¿î ½Ã±×³Î ó¸® ÇÔ¼ö ¼±¾ð */ int count = 0; /* Cntl-C ÀԷ Ƚ¼ö Ä«¿îÅÍ */ int main() { int i = 0; if(signal(SIGINT, my_signal) == SIG_ERR) { printf("singal() error\n"); return -1; } while(count < 3) { sleep(1); /* 1ÃÊ°£ ±â´Ù¸² */ printf("%d\n", i++); } } /* ½Ã±×³Î ó¸® ÇÔ¼ö Á¤ÀÇ */ int my_signal() { printf("\nCtrl-C pressed.\n"); count++; return 0; }