feat: manage task process lifetimes and preserve turn history

This commit is contained in:
Ed1s0nZ
2026-09-16 17:52:58 +08:00
parent fd1c13a43d
commit f7882be546
54 changed files with 3650 additions and 330 deletions
+11
View File
@@ -39,3 +39,14 @@ func terminateProcessGroup(rootPID int, cmd *exec.Cmd) {
func terminateCmdTree(cmd *exec.Cmd) {
terminateProcessGroup(0, cmd)
}
// stopProcessGroup gives the whole job a grace period to release resources.
func stopProcessGroup(pid int, cmd *exec.Cmd) {
if pid > 0 {
_ = syscall.Kill(-pid, syscall.SIGTERM)
}
}
func processGroupExists(pid int) bool {
return pid > 0 && syscall.Kill(-pid, 0) != syscall.ESRCH
}