feat: Ollama-Adapter gegen echtes Ollama geprüft, Vulkan und Runner-Prozesse behandelt (M2.6a)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 18:25:14 +01:00
parent 216fb47686
commit a52fcff603
14 changed files with 154 additions and 36 deletions

View File

@ -48,6 +48,30 @@ pub fn process_exists(pid: u32) -> bool {
send_signal(pid, 0)
}
/// Schickt ein Signal an eine ganze Prozessgruppe (der Gruppenführer hat die
/// PID `pgid`). Liefert `false`, wenn es die Gruppe nicht (mehr) gibt.
pub(crate) fn signal_group(pgid: u32, signal: i32) -> bool {
// SAFETY: wie bei `send_signal`; ein negativer PID adressiert die Gruppe.
unsafe { libc::kill(-(pgid as i32), signal) == 0 }
}
/// Beendet alle Prozesse einer Gruppe: erst `SIGTERM`, nach `grace` `SIGKILL`.
/// Gedacht für Prozesse, die den Gruppenführer überleben (Kindprozesse eines
/// hart beendeten Servers).
pub(crate) async fn terminate_group(pgid: u32, grace: Duration) {
if !signal_group(pgid, libc::SIGTERM) {
return;
}
let deadline = std::time::Instant::now() + grace;
while std::time::Instant::now() < deadline {
if !signal_group(pgid, 0) {
return;
}
tokio::time::sleep(Duration::from_millis(100)).await;
}
signal_group(pgid, libc::SIGKILL);
}
pub(crate) fn sigterm(pid: u32) -> bool {
send_signal(pid, libc::SIGTERM)
}