From 8be767d3c31901c449c0c88e5003ab18e879311c Mon Sep 17 00:00:00 2001 From: Ludea Date: Thu, 17 Oct 2024 15:50:47 +0000 Subject: [PATCH] make wait async and use ExitStatus crate --- plugins/shell/src/commands.rs | 8 +++----- plugins/shell/src/process/mod.rs | 6 ++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/shell/src/commands.rs b/plugins/shell/src/commands.rs index ed043813..771788b0 100644 --- a/plugins/shell/src/commands.rs +++ b/plugins/shell/src/commands.rs @@ -13,11 +13,10 @@ use tauri::{ use crate::{ open::Program, - process::{CommandEvent, TerminatedPayload}, + process::{CommandEvent, ExitStatus, TerminatedPayload}, scope::ExecuteArgs, Shell, }; -use std::process::ExitStatus; type ChildId = u32; @@ -304,14 +303,13 @@ pub fn kill( } #[tauri::command] -pub fn wait( +pub async fn wait( _window: Window, shell: State<'_, Shell>, pid: ChildId, ) -> crate::Result { if let Some(child) = shell.children.lock().unwrap().get(&pid) { - let exitstatus: ExitStatus = child.wait()?; - Ok(exitstatus) + child.wait().await } else { Err(crate::Error::UnknowChildProcess) } diff --git a/plugins/shell/src/process/mod.rs b/plugins/shell/src/process/mod.rs index 376eadc4..c0cc6d1e 100644 --- a/plugins/shell/src/process/mod.rs +++ b/plugins/shell/src/process/mod.rs @@ -86,9 +86,11 @@ impl CommandChild { } /// Waits for the child to exit completely, returning the status that it exited with. - pub fn wait(self) -> crate::Result { + pub async fn wait(self) -> crate::Result { let exitstatus = self.inner.wait()?; - Ok(exitstatus) + Ok(ExitStatus { + code: exitstatus.code(), + }) } }