How to make a free running counter resetable by pressing a key.
Linux kernel 2.16
Let clk be the counter. clk is always counting but, when I press a keyboard key it resets itself and starts over from zero. I go to make a coffee and, when coming back and begin typing again, if I also
have variable clk_old, I can know how much time I spent in the kitchen. Ok. The program is almost done but:
1) Can this be done by a script? If so, I'd need the whole script. I not:
2) Is there a signal that interrupts every, say 1s?
3) Please consider I'm new both to linux and to C. In another environment, this would seem a pretty simple program
for me to write.
The only concern, I think, is how to catch the signal and write the handler (only the body). Thanks for reading.