desktop AI fix: kill only the agent's own process group with killpg (never pgid <= 1 or our own group) instead of the external kill command; a Forgejo ci run of bc85dab died of SIGTERM in the middle of these tests
This commit is contained in:
parent
bc85dabf90
commit
f898d642d0
3 changed files with 14 additions and 2 deletions
1
apps/desktop/src-tauri/Cargo.lock
generated
1
apps/desktop/src-tauri/Cargo.lock
generated
|
|
@ -4016,6 +4016,7 @@ dependencies = [
|
|||
"getrandom 0.3.4",
|
||||
"hmac",
|
||||
"keyring",
|
||||
"libc",
|
||||
"reqwest",
|
||||
"rusqlite",
|
||||
"rustls",
|
||||
|
|
|
|||
|
|
@ -57,3 +57,6 @@ lto = true
|
|||
opt-level = "s"
|
||||
panic = "abort"
|
||||
strip = true
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = "0.2"
|
||||
|
|
|
|||
|
|
@ -304,9 +304,17 @@ fn running() -> &'static Running {
|
|||
pub fn kill_tree(pid: u32) {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let _ = Command::new("kill").args(["-TERM", &format!("-{pid}")]).status();
|
||||
// the agent runs in its own process group (pgid = its pid); never signal any other group, least of all ours
|
||||
// (a CI run once died of SIGTERM in the middle of these tests)
|
||||
let pgid = pid as libc::pid_t;
|
||||
// SAFETY: getpgrp has no preconditions; killpg only sends a signal to the group named
|
||||
let own = unsafe { libc::getpgrp() };
|
||||
if pgid <= 1 || pgid == own {
|
||||
return;
|
||||
}
|
||||
unsafe { libc::killpg(pgid, libc::SIGTERM) };
|
||||
std::thread::sleep(Duration::from_millis(300));
|
||||
let _ = Command::new("kill").args(["-KILL", &format!("-{pid}")]).status();
|
||||
unsafe { libc::killpg(pgid, libc::SIGKILL) };
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue