How it works...
Using the signal function, a signal interrupt, (SIGINT), is associated with a function called signalhandler1. That is, if the interrupt is autogenerated or is generated by the user, the sighandler1 function will be invoked. A counter, x, is initialized to 1 and a while loop is set to execute until the value of counter x becomes larger than 5. Within the while loop, the following text is displayed: Signal will be raised automatically after 5 seconds. In addition to this, the value of counter x is incremented by 1 within the while loop. A delay of 1 second is inserted in the while loop. In short, the while loop will display a text message after a gap of 1 second each. After displaying the text message 5 times, the raise function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access