FS#20538 - Do not buffer input from keyboard
Attached to Project:
Pacman
Opened by Mario Figueiredo (marfig) - Friday, 20 August 2010, 14:56 GMT
Last edited by Dave Reisner (falconindy) - Tuesday, 07 June 2011, 20:55 GMT
Opened by Mario Figueiredo (marfig) - Friday, 20 August 2010, 14:56 GMT
Last edited by Dave Reisner (falconindy) - Tuesday, 07 June 2011, 20:55 GMT
|
Details
Summary and Info:
Could pacman not collect input from the keyboard until it requests for it? If accidentally hit the enter key twice (to perform a -Syu for instance), or if I hit it during the time it is synchronizing or resolving dependencies, the key gets buffered and sent immediately on next input request. This may result in an unwanted action. Steps to Reproduce: Pacman -S <package> Pacman -Syu Perform above commands by tapping twice on the enter key |
This task depends upon
Closed by Dave Reisner (falconindy)
Tuesday, 07 June 2011, 20:55 GMT
Reason for closing: Implemented
Additional comments about closing: Commit: http://projects.archlinux.org/pacman.git /commit/?id=9477abc3591905a20acbfe7b8ce7 832617d72701
Tuesday, 07 June 2011, 20:55 GMT
Reason for closing: Implemented
Additional comments about closing: Commit: http://projects.archlinux.org/pacman.git /commit/?id=9477abc3591905a20acbfe7b8ce7 832617d72701
fflush(stdin);
Should work, if you place it before your getc. It will flush out any characters in the input buffer. Your getc will then wait for input.
I'm cool with this idea, but I'm going to need a working patch to make it happen as the obvious didn't work here.
http://sprunge.us/OiRX
Seems to work for me. I'm dubious as to the portability of such a feature, but it does appear to be specified by POSIX.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcflush.html
update: setup cygwin on my work machine and it compiles. tcflush even returns success. Someone in #archlinux compiled and ran for me on FreeBSD and they report the same.