mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-07-25 16:21:23 +00:00
Makes the Stop button on the traces page actually stop running traces. Seven-phase implementation across provider HTTP, agent router, trace persistence, WS events, tool exec, i18n, and integration tests. - Provider HTTP+SSE ctx-aware: close socket on cancel via CtxBody wrapper - Router 2-phase abort: CAS state machine, 3s grace, force-mark fallback - Trace retry: 3 inline retries + 10-max retry queue, stale recovery 10min - trace.status WS event: real-time UI updates (invalidates query on receive) - Tool exec: process-group kill (SIGTERM→3s→SIGKILL), Rod page ctx watch - i18n: 6 abort toast variants in en/vi/zh - Integration: 9 scenarios, -race clean Fixes tenant-ctx loss in forceMarkTraceAborted and retry worker broadcast (caught by code-reviewer: C1/C2). Stale threshold intentionally 10min because start_time-based; last_span_at migration is a follow-up.
31 lines
913 B
Go
31 lines
913 B
Go
//go:build !windows
|
|
|
|
package tools
|
|
|
|
import (
|
|
"os/exec"
|
|
"syscall"
|
|
)
|
|
|
|
// syscallSIGTERM and syscallSIGKILL are the platform signals used by executeOnHost.
|
|
// Defined here (unix) and as zero-value stubs in shell_pgid_windows.go.
|
|
const (
|
|
syscallSIGTERM = syscall.SIGTERM
|
|
syscallSIGKILL = syscall.SIGKILL
|
|
)
|
|
|
|
// setProcessGroup sets Setpgid so the child process becomes its own process-group leader.
|
|
// This allows killProcessGroup to signal the entire process tree (shell + forked children).
|
|
func setProcessGroup(cmd *exec.Cmd) {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
|
}
|
|
|
|
// killProcessGroup sends sig to the entire process group rooted at cmd.Process.Pid.
|
|
// Because Setpgid was set, pgid == pid, so kill(-pid, sig) reaches all forked children.
|
|
func killProcessGroup(cmd *exec.Cmd, sig syscall.Signal) error {
|
|
if cmd.Process == nil {
|
|
return nil
|
|
}
|
|
return syscall.Kill(-cmd.Process.Pid, sig)
|
|
}
|