You've already forked agentic-coding-workflow
feat(acp): supervisor spawn / handshake / monitor / kill / onExit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
//go:build !windows
|
||||
|
||||
package acp
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
// unixGracefulTerm 在 Unix 平台上先发 SIGTERM,等待 grace 时间内退出;
|
||||
// 否则 Process.Kill。done channel 由 monitorProcess 关闭。
|
||||
func (s *Supervisor) unixGracefulTerm(proc *Process, grace time.Duration) {
|
||||
if proc.Cmd.Process == nil {
|
||||
return
|
||||
}
|
||||
_ = proc.Cmd.Process.Signal(syscall.SIGTERM)
|
||||
select {
|
||||
case <-proc.done:
|
||||
return
|
||||
case <-time.After(grace):
|
||||
_ = proc.Cmd.Process.Kill()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user