fix(executor/local): use syscall kill
All checks were successful
build / build (push) Successful in 1m36s
build / trigger-build-image (push) Successful in 11s
submodules sync / sync (push) Successful in 36s

This commit is contained in:
张泊明518370910136 2025-03-21 04:37:37 -04:00
parent 14961db8f0
commit 2248d4e318
GPG Key ID: D47306D7062CDA9D

View File

@ -101,6 +101,7 @@ func (e *Local) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
for _, cmd := range cmds { for _, cmd := range cmds {
execCmd := exec.Command(cmd.Args[0], cmd.Args[1:]...) // #nosec G204 execCmd := exec.Command(cmd.Args[0], cmd.Args[1:]...) // #nosec G204
execCmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
if cmd.CPULimit > 0 && cmd.ClockLimit <= 0 { if cmd.CPULimit > 0 && cmd.ClockLimit <= 0 {
cmd.ClockLimit = cmd.CPULimit * 2 cmd.ClockLimit = cmd.CPULimit * 2
} }
@ -158,8 +159,8 @@ func (e *Local) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
) )
results = append(results, result) results = append(results, result)
case <-time.After(duration): case <-time.After(duration):
_ = execCmd.Process.Kill() _ = syscall.Kill(-execCmd.Process.Pid, syscall.SIGKILL)
err := execCmd.Wait() err := <-done
result := e.generateResult( result := e.generateResult(
err, err,
execCmd.ProcessState, execCmd.ProcessState,