修复windows下有时无法取消对话的情况

This commit is contained in:
xintaofei
2026-03-09 19:28:26 +08:00
parent 160326b703
commit 33a8d71985
3 changed files with 208 additions and 23 deletions

View File

@@ -149,11 +149,21 @@ impl TerminalInstance {
return Ok(());
};
if let Err(err) = child.kill().await {
if err.kind() != std::io::ErrorKind::InvalidInput {
return Err(TerminalRuntimeError::Internal(format!(
"failed to kill terminal process: {err}"
)));
#[cfg(target_os = "windows")]
{
if let Some(pid) = child.id() {
let _ = kill_tree::tokio::kill_tree(pid);
}
}
#[cfg(not(target_os = "windows"))]
{
if let Err(err) = child.kill().await {
if err.kind() != std::io::ErrorKind::InvalidInput {
return Err(TerminalRuntimeError::Internal(format!(
"failed to kill terminal process: {err}"
)));
}
}
}