Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crossterm v0.10.1 can't open raw mode when input is piped to stdin #188

Closed
timothyb89 opened this issue Aug 1, 2019 · 3 comments
Closed

Comments

@timothyb89
Copy link

In previous versions of crossterm (v0.8.2) it was possible to enable raw input mode when input was piped in, e.g.

echo "hello world" | my-crossterm-app

Using some trickery, you could continuously read piped output while still receiving key events. However, in crossterm v0.10 (and probably since the big v0.9 refactor, but I haven't confirmed), RawScreen::into_raw_mode() returns an error if input is piped into the app:

Os { code: 25, kind: Other, message: "Inappropriate ioctl for device" }

I've made a small demo of this working in v0.8 but breaking in v0.10: https://github.com/timothyb89/crossterm-stdin-test

@andersk
Copy link
Contributor

andersk commented Sep 17, 2019

Surely into_raw_mode should be conceptually an operation on stdin, not stdout? Then you could call it on any fd that you think is a terminal, whether it happens to be fd 0 or not. In addition to that problem, some applications may want to set input to raw mode even if they aren’t using crossterm at all for output.

The docs have an explanation of why it wasn’t written that way, but the explanation is manifestly wrong—the underlying code, at least on Unix, calls operations on fd 0 (stdin), not fd 1 (stdout).

andersk added a commit to andersk/crossterm-utils that referenced this issue Oct 5, 2019
As discussed in crossterm-rs/crossterm#188,
the terminal might not be stdin.

Signed-off-by: Anders Kaseorg <[email protected]>
andersk added a commit to andersk/crossterm-utils that referenced this issue Oct 5, 2019
As discussed in crossterm-rs/crossterm#188,
the terminal might not be stdin.

Signed-off-by: Anders Kaseorg <[email protected]>
andersk added a commit to andersk/crossterm-utils that referenced this issue Oct 5, 2019
As discussed in crossterm-rs/crossterm#188,
the terminal might not be stdin.

Signed-off-by: Anders Kaseorg <[email protected]>
andersk added a commit to andersk/crossterm-utils that referenced this issue Oct 5, 2019
As discussed in crossterm-rs/crossterm#188,
the terminal might not be stdin.

Signed-off-by: Anders Kaseorg <[email protected]>
@TimonPost
Copy link
Member

Sorry I have never responded to this issue. Since basically, the whole crossterm library was refactored after 0.10 and we have been moving over to /dev/tty for everything this issue might be resolved. I'll close it for now.

@timothyb89
Copy link
Author

Thanks for the update! I'll give it a try and report back if there's still trouble.

december1981 pushed a commit to december1981/crossterm that referenced this issue Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants