Opening console/terminal handle with user input #21390

Closed
opened 2026-01-31 07:43:17 +00:00 by claunia · 3 comments
Owner

Originally created by @ShrykeWindgrace on GitHub (Mar 12, 2024).

Hi!

I have a TUI app that reads some input from piped stdin and then shows something interactively to the user: tail -f log.txt | myTuiApp.

In order to do that on a linux machine, I'd grab stdin for reading those logs and openFile "/dev/tty" ReadMode to get user input (this is Haskell code, but you can surely get the idea).

In WT world I tried opening openFile "\\\\.\\CON" ReadMode, which opens a handle, but does not allow, e.g. setting console mode (and I need that to change buffering, enable VT processing, etc). I get a SetConsoleMode: permission denied (Access is denied.)

What is the canonical way to get a handle with user input if stdin is piped?

I have a Win10 with WT-1.19.10573.0

Originally created by @ShrykeWindgrace on GitHub (Mar 12, 2024). Hi! I have a TUI app that reads some input from piped stdin and then shows something interactively to the user: `tail -f log.txt | myTuiApp`. In order to do that on a linux machine, I'd grab `stdin` for reading those logs and `openFile "/dev/tty" ReadMode` to get user input (this is Haskell code, but you can surely get the idea). In WT world I tried opening `openFile "\\\\.\\CON" ReadMode`, which opens a handle, but does not allow, e.g. setting console mode (and I need that to change buffering, enable VT processing, etc). I get a `SetConsoleMode: permission denied (Access is denied.)` What is the canonical way to get a handle with user input if `stdin` is piped? I have a Win10 with `WT-1.19.10573.0`
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-31 07:43:17 +00:00
Author
Owner

@DHowett commented on GitHub (Mar 12, 2024):

Try opening CONIN$ instead!

@DHowett commented on GitHub (Mar 12, 2024): Try opening `CONIN$` instead!
Author
Owner

@ShrykeWindgrace commented on GitHub (Mar 12, 2024):

@DHowett That indeed did the trick! Thanks a lot!

openFile "\\\\.\\CONIN$" ReadWriteMode
@ShrykeWindgrace commented on GitHub (Mar 12, 2024): @DHowett That indeed did the trick! Thanks a lot! ```haskell openFile "\\\\.\\CONIN$" ReadWriteMode ```
Author
Owner

@DHowett commented on GitHub (Mar 12, 2024):

Happy to help!

@DHowett commented on GitHub (Mar 12, 2024): Happy to help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21390