No way to poll() on terminal input (API problem) #9918

Open
opened 2026-01-31 02:07:23 +00:00 by claunia · 0 comments
Owner

Originally created by @ghost on GitHub (Jul 29, 2020).

Environment

Microsoft Windows [Version 10.0.18363.836]

Steps to reproduce

Neither select(), nor that WSA poll-like function, nor I/O completion ports can perform async I/O on a console handle.

Expected behavior

Async I/O is somehow possible, preferably via POSIX poll().

Actual behavior

It is not possible to do asynchronous I/O on the console. It is not possible to use overlapped I/O (aka I/O completion ports) on console handles. All I/O blocks until enter is hit (i.e. a line is complete, and sent to the reader).

Note that this is specifically when line discipline is enabled. I'm not really interested in essentially observing key strokes and implementing the rest myself. Simple things should be simple. Consider that a stdin handle is not necessarily a terminal, but could e.g. be a pipe.

I heard WaitForMultipleObjects is supposed to work. AFAIR this is not the case, though I can't be 100% sure.


Yes, this is an API bug. Unsure whether it's in scope of this repository. It seems to be the closest though.

Originally created by @ghost on GitHub (Jul 29, 2020). # Environment Microsoft Windows [Version 10.0.18363.836] # Steps to reproduce Neither select(), nor that WSA poll-like function, nor I/O completion ports can perform async I/O on a console handle. # Expected behavior Async I/O is somehow possible, preferably via POSIX poll(). # Actual behavior It is not possible to do asynchronous I/O on the console. It is not possible to use overlapped I/O (aka I/O completion ports) on console handles. All I/O blocks until enter is hit (i.e. a line is complete, and sent to the reader). Note that this is specifically when line discipline is enabled. I'm not really interested in essentially observing key strokes and implementing the rest myself. Simple things should be simple. Consider that a stdin handle is not _necessarily_ a terminal, but could e.g. be a pipe. I heard WaitForMultipleObjects is supposed to work. AFAIR this is not the case, though I can't be 100% sure. --- Yes, this is an API bug. Unsure whether it's in scope of this repository. It seems to be the closest though.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9918