ncurses strangeness?
Hi,
I will toying with ncurses and found this strange behaviour:
On GNU/Linux, the program exits (as I expect) when "q" is pressed.
On GNU/Hurd, it does not.
[I compiled also for SGI IRIX (using curses) and the program
does exit, but also logs me out(!).]
My C programming skills are sadly week, so it may also due to a
bug in the program...
Help?
Thanks,
Paul.
--
#include <ncurses.h>
int
wait_and_check_for_quit() {
int max_loop = 10;
int i;
int chr;
for (i=0; i<max_loop; i++) {
chr=getch();
if (chr == 'q') {
exit(0);
}
usleep(100000); /* 0.1 seconds */
}
/* we got to the end and q has not been pressed */
return FALSE;
}
int
main(int argc, char **argv) {
initscr();
noecho();
cbreak();
keypad (stdscr, TRUE);
leaveok(stdscr, TRUE); /* no cursor */
nodelay(stdscr, TRUE); /* don't wait for keypress */
while(1) {
if (wait_and_check_for_quit() == TRUE) { /* let's exit */
return 0;
}
}
}
Reply to: