Commit b44fedc9 authored by AdminXVII's avatar AdminXVII

fix(readln): Make sure to reset the O_FLAGS when reading lines

When some binaries set the TTY to non-blocking mode, the shell would panic because of a nonblock error. Fix this by reseting the O_FLAGS while reading lines
parent ca2bcc4c
This diff is collapsed.
......@@ -79,7 +79,7 @@ structopt = "0.3"
atty = "0.2"
permutate = "0.3"
xdg = "2.1"
nix = { git = "https://github.com/AdminXVII/nix", branch = "add-redox-support" }
nix = { git = "https://github.com/AdminXVII/nix", branch = "add-redox-support-bis" }
mktemp = "0.4"
# window example
......
use super::{completer::IonCompleter, InteractiveShell};
use ion_shell::Shell;
use std::io::ErrorKind;
use nix::fcntl::{OFlag, fcntl, FcntlArg};
impl<'a> InteractiveShell<'a> {
/// Make sure to reset the fd to blocking mode
fn to_blocking(fd: std::os::unix::io::RawFd) {
fcntl(fd, FcntlArg::F_SETFL(OFlag::O_RDWR)).unwrap();
}
/// Ion's interface to Liner's `read_line` method, which handles everything related to
/// rendering, controlling, and getting input from the prompt.
pub fn readln<T: Fn(&mut Shell<'_>)>(&self, prep_for_exit: &T) -> Option<String> {
Self::to_blocking(0);
Self::to_blocking(1);
Self::to_blocking(2);
let prompt = self.prompt();
let line = self.context.borrow_mut().read_line(
prompt,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment