Commit 19255a22 authored by jocutajar's avatar jocutajar

Try debug sudden death

parent 85a3b19a
......@@ -11,16 +11,23 @@ use sys::tty::get_tty;
pub fn async_stdin_until(delimiter: u8) -> AsyncReader {
let (send, recv) = mpsc::channel();
thread::spawn(move || for i in get_tty().unwrap().bytes() {
match i {
Ok(byte) => {
let end_of_stream = &byte == &delimiter;
let send_error = send.send(Ok(byte)).is_err();
if end_of_stream || send_error { return; }
},
Err(_) => { return; }
thread::spawn(move || {
for i in get_tty().unwrap().bytes() {
match i {
Ok(byte) => {
let end_of_stream = &byte == &delimiter;
let send_error = send.send(Ok(byte)).is_err();
if end_of_stream || send_error {
warn!("Send error");
return;
}
}
Err(e) => {
warn!("Read error: {}", e);
return;
}
}
}
});
......@@ -40,11 +47,13 @@ pub fn async_stdin_until(delimiter: u8) -> AsyncReader {
pub fn async_stdin() -> AsyncReader {
let (send, recv) = mpsc::channel();
thread::spawn(move || for i in get_tty().unwrap().bytes() {
if send.send(i).is_err() {
return;
}
});
thread::spawn(move || {
for i in get_tty().unwrap().bytes() {
if send.send(i).is_err() {
return;
}
}
});
AsyncReader { recv: recv }
}
......@@ -80,7 +89,10 @@ impl Read for AsyncReader {
total += 1;
}
Ok(Err(e)) => return Err(e),
Err(_) => break,
Err(e) => {
warn!("Receive error {}", e);
break;
}
}
}
......
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