So, at a high level, here's the step-by-step plan for the program (the actual code is shown in the following section; we suggest you first read this and then check out the code):
- Create and initialize a simple alarm; program it to expire at a random time—anywhere between 1 and 5 seconds from the program's start
- The moment the alarm expires, do the following:
- Arm a POSIX (interval) timer (to the frequency specified in the first parameter).
- Display a message requesting the user to press Ctrl + C on the keyboard
- Take a timestamp (let's call it tm_start).
- When the user actually presses ^C (Ctrl + C; which we will know, simply, by trapping SIGINT via sigaction(2)), again, take a timestamp (let's call it tm_end ...