Re: Gracefully stopping an infinite loop after a particular keyboard input




Ranjan schrieb:

I am having a script that is doing some tests continuously. I am
running it from cygwin under Windows OS and is currently using CTRL+C
to stop the script. But by "ctrl+c" the script stops at that very
moment. In between there are some read write operations going on files
and when the script stops atonce.

I want that when I press any key say "Q" from keyboard , the script
should complete that particular loop and then stop. (Hope I am able to
clarify my problem).

A simple solution might be, that you just test within the loop if the
button has beed pressed? Or maybe i didn't get the problem correctly.
Without testing around, i would assume, that if should work with the
fconfigure / fileevent
commands (in combination with stdin).
Hope this helps,

Friedemann

.