Skip to content

read_key goes into an endless loop and eventually exhausts file handles #168

@mitsuhiko

Description

@mitsuhiko

Minimal repo case:

use console::Term;

fn main() {
    eprintln!("Press any key to exist");
    Term::stderr().read_key().unwrap();
}

If this script is compiled and run with a close stdin (cat | target/debug/repro) it will fail with

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 24, kind: Uncategorized, message: "Too many open files" }'

The issue is that read_single_key has a condition where it will call back into itself recursively.

Refs astral-sh/rye#184

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