Files
tiennm99 fb61a57785 feat: implement personal AI agent gateway with Telegram channel and exec policy engine
YAML config with env-indirected secrets, SQLite persistence, OpenAI provider, think/act/observe agent loop, fs/web_fetch/exec tools behind deny->allow->mode policy with approval flows, Telegram long-polling channel with gating and inline approvals, gateway with per-session serialization + instance lock + graceful shutdown, cron scheduler.
2026-08-01 18:19:27 +07:00

26 lines
699 B
Go

//go:build !windows
package tools
import (
"os/exec"
"syscall"
)
// setProcessGroup puts cmd's child in its own process group (setpgid) so
// killProcessTree can signal the whole group - the child and anything it
// forked - in one syscall instead of only the direct child.
func setProcessGroup(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}
// killProcessTree sends SIGKILL to cmd's entire process group. The negative
// pid is the POSIX convention for "the process group led by this pid",
// which setProcessGroup made cmd's own pid.
func killProcessTree(cmd *exec.Cmd) {
if cmd.Process == nil {
return
}
_ = syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
}