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::{
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<R: Runtime>(
}
#[tauri::command]
pub fn wait<R: Runtime>(
pub async fn wait<R: Runtime>(
_window: Window<R>,
shell: State<'_, Shell<R>>,
pid: ChildId,
) -> crate::Result<ExitStatus> {
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)
}

@ -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<std::process::ExitStatus> {
pub async fn wait(self) -> crate::Result<ExitStatus> {
let exitstatus = self.inner.wait()?;
Ok(exitstatus)
Ok(ExitStatus {
code: exitstatus.code(),
})
}
}

Loading…
Cancel
Save