hi, can anyone tell me What is the effect of the statement:
actn.sa_flags = SA_RESTART;
and what changes would you make to the program to get it to behave in the same way if this statement were to be left out?
the following is the full program..
cheers,
Atif.
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <setjmp.h>
#define SA_NULL (struct sigaction *)0
int toolong;
void wakeup(int);
int number;
int count = 0;
jmp_buf savbuf;
main()
{
struct sigaction actn;
actn.sa_handler = wakeup;
sigfillset( &(actn.sa_mask) );
actn.sa_flags = SA_RESTART; //what is the effect of this statement
sigaction(SIGALRM, &actn, SA_NULL);
for(;
{
printf("Enter number: ");
toolong = 0;
alarm(10);
if ( 0 == setjmp(savbuf) ) scanf("%d", &number);
if ( !toolong ) break;
if ( count == 1 ) /*First message*/
printf("\nSee your ID card.\n");
else /*Final message*/
{
printf("Time expired!\n");
exit(1);
}
}
alarm(0);
printf("Number: %d\n", number);
}
void wakeup(int a)
{
toolong = 1;
count++;
printf("*********\n");
longjmp(savbuf, 1 );
}