Here is the code that can help you
Code:
sigc cntal;
void galarm(int numSig) (
siglongjmp( cntal, 1); / * connection has sigsetjmp () returning a * /
)
int hand(void) (
int i;
/ * Installation the handler for SIGALRM galarm * /
signal(SIGALRM, galarm);
/ * Processing * /
printf("You have five seconds to enter an integer\ n");
/ * Memorization of execution context * /
if (! sigsetjmp(cntal, 1)) ( / * first pass * /
alarm(5); / * Set up the timer * /
scanf("% d", & i); alarm(0); / * seizure effected, we cancel the timer * /
printf("OK:% s entered\ n", i);
)
else (
printf("Nothing entered. Bye!\ n");
)
return(0);
Bookmarks