winio: make console read non blocking not wait for any events
requested to merge Phyx/ghc:wip/winio-make-consoleReadNonBlocking-not-wait-for-any-events into master
The hGetBufNonBlocking is unused in GHC itself, but at least the documentation suggests it shouldn't ever block.
ReadConsoleInput does block until there's a console event available. Which is fine for consoleRead but not so for consoleReadNonBlocking.
So we just have to check the number of available events before calling ReadConsoleInput.
Fixes #21665 (closed)
Needs a rebase after !8359 (closed)
Note that while I want to write a testcase for this, it's impossible as the testsuite:
- runs inside msys2, the stdhandles are pipes then (which is why test don't fail atm)
- the handles are redirected by the testsuite to new pipes. So again, won't allow the use of native consoles.
Edited by Tamar Christina