October 2018
Beginner
794 pages
19h 23m
English
This simple program will allow you to set up the number of seconds to run and to walk. It will time out accordingly.
In this application, we use a simple one-shot POSIX timer to do the job. We set the timer to use signal notification as the timer expiry notification mechanism. We set up a signal handler for a RT signal (SIGRTMIN). Next, we initially set the POSIX timer to expire after the run period, then, when the signal does arrive in the signal handler, we reset (re-arm) the timer to expire after the walk period seconds. This essentially repeats forever, or until the user aborts the program by pressing ^C.