diff --git a/crates/nu-plugin-engine/src/gc.rs b/crates/nu-plugin-engine/src/gc.rs index bd9c8de06f..572a61b2a9 100644 --- a/crates/nu-plugin-engine/src/gc.rs +++ b/crates/nu-plugin-engine/src/gc.rs @@ -85,16 +85,26 @@ impl PluginGc { pub fn exited(&self) { let _ = self.sender.send(PluginGcMsg::Exited); } + + /// Tell the GC that our process received a Ctrl-C signal + pub fn ctrlc(&self) { + let _ = self.sender.send(PluginGcMsg::Ctrlc); + } + + pub fn clone_sender(&self) -> mpsc::Sender { + self.sender.clone() + } } #[derive(Debug)] -enum PluginGcMsg { +pub enum PluginGcMsg { SetConfig(PluginGcConfig), Flush(mpsc::Sender<()>), AddLocks(i64), SetDisabled(bool), StopTracking, Exited, + Ctrlc, } #[derive(Debug)] @@ -160,6 +170,9 @@ impl PluginGcState { // Exit and stop the plugin return Some(true); } + PluginGcMsg::Ctrlc => { + eprintln!("Ctrl-C received, plugin: `{}`", self.name); + } } None } diff --git a/crates/nu-plugin-engine/src/persistent.rs b/crates/nu-plugin-engine/src/persistent.rs index 5f01c70ca7..a8682d22be 100644 --- a/crates/nu-plugin-engine/src/persistent.rs +++ b/crates/nu-plugin-engine/src/persistent.rs @@ -178,6 +178,9 @@ impl PersistentPlugin { // Start the plugin garbage collector let gc = PluginGc::new(mutable.gc_config.clone(), &self)?; + // I need the current EngineState here + eprintln!("gc.sender: {:?}", gc.clone_sender()); + let pid = child.id(); let interface = make_plugin_interface(