Skip to content

On MacOS, crossterm::cursor::position() freezes the program when stdin is piped #828

@glcraft

Description

@glcraft

Describe the bug
When using crossterm::cursor::position() when stdin comes from another program (piped input), the program freezes and doesn't respond to any other event. When it occurs, it's impossible to quit the program by pressing Ctrl+C. The shell launching the program also get some trouble (nushell blocks, zsh get its size wrong).

The issue is not reproductible on Linux. I haven't tried on Windows yet.

To Reproduce

  1. Minimal code :
fn main() {
    let current_line_pos = crossterm::cursor::position().unwrap().1;
}
  1. run the code with piped input :
    on zsh
cargo r <<< test

on nushell

"test" | cargo r

Expected behavior
Not to freeze 😄

OS
MacOS Ventura 15.5.2

Terminal/Console
Tried on iTerm2 and vscode integrated console.
Launched with nushell and zsh.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions