diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-02-25 20:59:40 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-02-25 20:59:40 -0500 |
commit | b8f61109f7d22a09458d78681155150f39a12269 (patch) | |
tree | dd2c67ae51413bd842dea9c86ac4ac3389d6e5e7 /src/shell/history | |
parent | 31d2bd9dfc8da6cec159f38c28f3220c8b538d34 (diff) | |
download | nbsh-b8f61109f7d22a09458d78681155150f39a12269.tar.gz nbsh-b8f61109f7d22a09458d78681155150f39a12269.zip |
don't error when sending events during application shutdown
Diffstat (limited to 'src/shell/history')
-rw-r--r-- | src/shell/history/entry.rs | 4 | ||||
-rw-r--r-- | src/shell/history/mod.rs | 10 | ||||
-rw-r--r-- | src/shell/history/pty.rs | 8 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/shell/history/entry.rs b/src/shell/history/entry.rs index 97e8a7b..ac3a279 100644 --- a/src/shell/history/entry.rs +++ b/src/shell/history/entry.rs @@ -341,11 +341,11 @@ impl Entry { pub async fn finish( &mut self, env: Env, - event_w: tokio::sync::mpsc::UnboundedSender<Event>, + event_w: crate::shell::event::Writer, ) { self.state = State::Exited(ExitInfo::new(env.latest_status())); self.env = env; - event_w.send(Event::PtyClose).unwrap(); + event_w.send(Event::PtyClose); } fn exit_info(&self) -> Option<&ExitInfo> { diff --git a/src/shell/history/mod.rs b/src/shell/history/mod.rs index 2eeab0b..6d38891 100644 --- a/src/shell/history/mod.rs +++ b/src/shell/history/mod.rs @@ -86,7 +86,7 @@ impl History { &mut self, cmdline: &str, env: &Env, - event_w: tokio::sync::mpsc::UnboundedSender<Event>, + event_w: crate::shell::event::Writer, ) -> anyhow::Result<usize> { let (input_w, input_r) = tokio::sync::mpsc::unbounded_channel(); let (resize_w, resize_r) = tokio::sync::mpsc::unbounded_channel(); @@ -223,7 +223,7 @@ fn run_commands( mut env: Env, input_r: tokio::sync::mpsc::UnboundedReceiver<Vec<u8>>, resize_r: tokio::sync::mpsc::UnboundedReceiver<(u16, u16)>, - event_w: tokio::sync::mpsc::UnboundedSender<Event>, + event_w: crate::shell::event::Writer, ) { tokio::task::spawn(async move { let pty = match pty::Pty::new( @@ -278,7 +278,7 @@ async fn spawn_commands( cmdline: &str, pty: &pty::Pty, env: &mut Env, - event_w: tokio::sync::mpsc::UnboundedSender<Event>, + event_w: crate::shell::event::Writer, ) -> anyhow::Result<std::process::ExitStatus> { enum Res { Read(crate::runner::Event), @@ -339,10 +339,10 @@ async fn spawn_commands( match res { Res::Read(event) => match event { crate::runner::Event::RunPipeline(idx, span) => { - event_w.send(Event::ChildRunPipeline(idx, span)).unwrap(); + event_w.send(Event::ChildRunPipeline(idx, span)); } crate::runner::Event::Suspend(idx) => { - event_w.send(Event::ChildSuspend(idx)).unwrap(); + event_w.send(Event::ChildSuspend(idx)); } crate::runner::Event::Exit(new_env) => { *env = new_env; diff --git a/src/shell/history/pty.rs b/src/shell/history/pty.rs index acfe500..8825f12 100644 --- a/src/shell/history/pty.rs +++ b/src/shell/history/pty.rs @@ -11,7 +11,7 @@ impl Pty { entry: &crate::mutex::Mutex<super::Entry>, input_r: tokio::sync::mpsc::UnboundedReceiver<Vec<u8>>, resize_r: tokio::sync::mpsc::UnboundedReceiver<(u16, u16)>, - event_w: tokio::sync::mpsc::UnboundedSender<Event>, + event_w: crate::shell::event::Writer, ) -> anyhow::Result<Self> { let (close_w, close_r) = tokio::sync::mpsc::unbounded_channel(); @@ -49,7 +49,7 @@ async fn pty_task( input_r: tokio::sync::mpsc::UnboundedReceiver<Vec<u8>>, resize_r: tokio::sync::mpsc::UnboundedReceiver<(u16, u16)>, close_r: tokio::sync::mpsc::UnboundedReceiver<()>, - event_w: tokio::sync::mpsc::UnboundedSender<Event>, + event_w: crate::shell::event::Writer, ) { enum Res { Read(Result<bytes::Bytes, std::io::Error>), @@ -80,7 +80,7 @@ async fn pty_task( Res::Read(res) => match res { Ok(bytes) => { entry.clone().lock_owned().await.process(&bytes); - event_w.send(Event::PtyOutput).unwrap(); + event_w.send(Event::PtyOutput); } Err(e) => { panic!("pty read failed: {:?}", e); @@ -93,7 +93,7 @@ async fn pty_task( .resize(pty_process::Size::new(size.0, size.1)) .unwrap(), Res::Close(()) => { - event_w.send(Event::PtyClose).unwrap(); + event_w.send(Event::PtyClose); return; } } |