Open
Description
This has been mentioned before but I don't think there's a dedicated issue for it.
The standard streams on Windows are blocking. On Unix systems, on the other hand, they are non-blocking for TTYs. It allows to continue other fibers while waiting on IO. This is particularly relevant for STDIN
.
For example, the following program prints the current time and updates it every second, while pressing enter aborts.
spawn do
loop do
print Time.utc.to_s("%H:%M:%S\r")
sleep 1.second
end
end
STDIN.gets
On Windows, it doesn't print anything because STDIN.gets
is blocking and the loop fiber never gets a chance to execute.
We should have the same behaviour as on Unix. I'm not sure how we can best achieve it.
- We're already detecting whether the standard streams are a console. So this information can be used.
- It might be possible that we can set
blocking: false
inFileDescriptor.from_stdio
on Windows. This certainly requires Support asynchronous file I/O on Windows #14321 and maybe something else. We would probably have to duplicate the file descriptor as we do on Unix, in order to avoid problems with the parent process. But I'm not sure about the Windows mechanics here. - The Win32 API also provides special functions for dealing with console handles, such as
GetNumberOfConsoleInputEvents
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
In Progress