make wait async and use ExitStatus crate

pull/1947/head
Ludea 9 months ago
parent 9ebfbf0296
commit 8be767d3c3

@ -13,11 +13,10 @@ use tauri::{
use crate::{ use crate::{
open::Program, open::Program,
process::{CommandEvent, TerminatedPayload}, process::{CommandEvent, ExitStatus, TerminatedPayload},
scope::ExecuteArgs, scope::ExecuteArgs,
Shell, Shell,
}; };
use std::process::ExitStatus;
type ChildId = u32; type ChildId = u32;
@ -304,14 +303,13 @@ pub fn kill<R: Runtime>(
} }
#[tauri::command] #[tauri::command]
pub fn wait<R: Runtime>( pub async fn wait<R: Runtime>(
_window: Window<R>, _window: Window<R>,
shell: State<'_, Shell<R>>, shell: State<'_, Shell<R>>,
pid: ChildId, pid: ChildId,
) -> crate::Result<ExitStatus> { ) -> crate::Result<ExitStatus> {
if let Some(child) = shell.children.lock().unwrap().get(&pid) { if let Some(child) = shell.children.lock().unwrap().get(&pid) {
let exitstatus: ExitStatus = child.wait()?; child.wait().await
Ok(exitstatus)
} else { } else {
Err(crate::Error::UnknowChildProcess) Err(crate::Error::UnknowChildProcess)
} }

@ -86,9 +86,11 @@ impl CommandChild {
} }
/// Waits for the child to exit completely, returning the status that it exited with. /// Waits for the child to exit completely, returning the status that it exited with.
pub fn wait(self) -> crate::Result<std::process::ExitStatus> { pub async fn wait(self) -> crate::Result<ExitStatus> {
let exitstatus = self.inner.wait()?; let exitstatus = self.inner.wait()?;
Ok(exitstatus) Ok(ExitStatus {
code: exitstatus.code(),
})
} }
} }

Loading…
Cancel
Save