The following are the steps for associating signals to signal-handling functions, automatically raise the signals, and get the desired actions performed when signals are raised by user actions:
- Associate a signal interrupt, (SIGINT), to a function. This function will act as a signal handler.
- Write some code in the signal handler function.
- In the main function, make a while loop that executes 5 times. You can make the while loop run for as many times as you want. The while loop is set to display a text message after a delay of 1 second.
- The idea is to automatically raise the signal after 5 seconds. So, after its 5 iterations, the while loop ends and the interrupt signal is automatically raised.
- The associated signal handler ...