Skip to content

Commit a6f2c91

Browse files
committed
fix: Windows 平台兼容性 - 使用 cfg 条件编译处理进程取消
1 parent 1cc8434 commit a6f2c91

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

src-tauri/src/lib.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5894,14 +5894,25 @@ fn cancel_claude_code_install() -> Result<(), String> {
58945894
return Err("No install process running".to_string());
58955895
}
58965896

5897-
// Use pkill to kill child processes first (curl, bash, etc.)
5898-
let _ = std::process::Command::new("pkill")
5899-
.args(["-9", "-P", &pid.to_string()])
5900-
.output();
5897+
#[cfg(unix)]
5898+
{
5899+
// Use pkill to kill child processes first (curl, bash, etc.)
5900+
let _ = std::process::Command::new("pkill")
5901+
.args(["-9", "-P", &pid.to_string()])
5902+
.output();
5903+
5904+
// Kill the main process with SIGKILL
5905+
unsafe {
5906+
libc::kill(pid as i32, libc::SIGKILL);
5907+
}
5908+
}
59015909

5902-
// Kill the main process with SIGKILL
5903-
unsafe {
5904-
libc::kill(pid as i32, libc::SIGKILL);
5910+
#[cfg(windows)]
5911+
{
5912+
// On Windows, use taskkill to terminate the process tree
5913+
let _ = std::process::Command::new("taskkill")
5914+
.args(["/F", "/T", "/PID", &pid.to_string()])
5915+
.output();
59055916
}
59065917

59075918
CC_INSTALL_PID.store(0, std::sync::atomic::Ordering::SeqCst);

0 commit comments

Comments
 (0)