Listening to stdin while performing certain operations
Hi!
I'm trying to write a program, based on following ideas:
- while not interrupted, program is performing some operations, then goes in sleep/wait state for a minute, then again - operations, and sleep/wait state...
- if interrupted (user inserts a command), program handles the command and then goes back to his work/sleep loop.
My question is if there is a way to make my program sleep, but at the same time monitor standard input, to handle the command immediately if given. I would rather not create two thread application.
Big thanks in advance!
[edit]
Ah, of course: I'm looking rather for a C++ solution.