How to make a free running counter resetable by pressing a key.
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to make a free running counter resetable by pressing a key.
Linux kernel 2.16
Hi:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.