-   Linux - Software (
-   -   How to make a free running counter resetable by pressing a key. (

stf92 05-24-2009 10:29 AM

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.

fpmurphy 05-24-2009 10:31 AM

This sounds like homework

stf92 05-24-2009 10:33 AM

I forgot. Compiler: gcc (GCC) 4.1.2.

stf92 05-24-2009 10:39 AM

Beleave me. I'm not. I program since a youngster. Thanks for

H_TeXMeX_H 05-24-2009 10:41 AM

It's possible to do with a script, likely with awk:

stf92 05-24-2009 10:46 AM

Thanks a lot. It's first thing I want do with linux, learning scripts, since I've seen i go nowhere without understanding them. There's also the other alternative. Isolate one self in the language, and all between the compiler and os. Thanks again.

All times are GMT -5. The time now is 04:02 AM.