-
-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Description
On Unix, read_secure_line first checks whether stdin is a TTY, and if not falls back to /dev/tty.
Line 72 in de2f15a
| } else { |
But when I tried
use std::error::Error;
use console::Term;
fn main() -> Result<(), Box<dyn Error>> {
let term = Term::stdout();
let x = term.read_secure_line()?;
dbg!(x);
Ok(())
}with echo hello-world | target/debug/mytest
it hangs until I press return, after which it prints
Error: Os { code: 9, kind: Uncategorized, message: "Bad file descriptor" }
I don't think this should happen?
A bit of printf debugging revealed this line to be the source of the error
Line 97 in de2f15a
| c_result(|| unsafe { libc::tcsetattr(fd, libc::TCSAFLUSH, &original) })?; |
procfs reveals that the FD has been closed at that point.
and further debugging reveals that, indeed, someone is doing a little bit of FD closing.
Line 91 in de2f15a
| let read_rv = if let Some(mut f) = f_tty { |
this line moves out of f_tty, which closes the File.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels