- Subject: [slang-users] Does SLang_input_pending() block on receiving the abort character?
- From: Nate Bargmann <n0nb@xxxxxxx>
- Date: Mon, 6 Jan 2014 20:39:03 -0600
I'm looking through the docs and played with the listing in section 6.5
of the S-Lang C Programmer's Guide. The listing is written so that it
would appear that SLang_input_pending() passes the abort character to
SLang_getkey() so that the test of SL_UserBreak_Error would result in
the Ctl-G message being printed. However, I am seeing the timeout
message instead as from this run:
$ ./slgetkey
Press any key. To quit, press Ctrl-G: g
Press any key. To quit, press Ctrl-G: s
Press any key. To quit, press Ctrl-G: k
Press any key. To quit, press Ctrl-G: e
Press any key. To quit, press Ctrl-G: Waited too long! Bye
The last line was printed immdiately upon pressing Ctl-G.
I modified the call to SLang_input_pending() to put it into an infite
while loop as follows:
while (SLang_input_pending(5) == 0) {
continue;
}
And the output is:
$ ./slgetkey
Press any key. To quit, press Ctrl-G: The character is: f
Press any key. To quit, press Ctrl-G: The character is: g
Press any key. To quit, press Ctrl-G: The character is: h
Press any key. To quit, press Ctrl-G: Ctrl-G pressed! Bye
$ j
After pressing 'h' I pressed Ctl-G and the program is blocked until I
typed 'j' then it passed the test of SL_UserBreak_Error and printed the
Ctl-G message. After exiting the 'j' character was printed to the
screen after the shell flushed the buffer.
I am running Debian Linux Unstable, Xfce Terminal, and Bash for the
shell.
- Nate
--
"The optimist proclaims that we live in the best of all
possible worlds. The pessimist fears this is true."
Ham radio, Linux, bikes, and more: http://www.n0nb.us
[2014 date index]
[2014 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]