/* You may use this code in your project for catching the interrupt signal * (SIGINT) generated by the user. It is taken with minor modifications * from page 135 of Haviland, Gray, and Salama. */ #include int main(){ static struct sigaction act; /* declare the function to be used later as the handler */ void catchint(int); /* set up the action to be taken on receipt of SIGINT */ act.sa_handler = catchint; /* create a full mask to block other signals */ sigfillset (&(act.sa_mask)); /* tell OS to pass control to catchint when SIGINT occurs */ sigaction (SIGINT, &act, NULL); /* PUT YOUR LOOP FOR THE CALCULATIONS HERE */ exit(0); } /* Function to handle SIGINT */ void catchint (int signo){ /* PUT YOUR CODE FOR PROCESSING A CTRL-C HERE */ }