Files
multica/server/internal/daemon/execenv/isolation_unix.go
Bohan Jiang ed57707bb2 MUL-4923: bound daemon task preparation time (#5584)
* fix(daemon): bound pre-start task preparation

Co-authored-by: multica-agent <github@multica.ai>

* fix(daemon): isolate pre-start env preparation

Run execution-environment Prepare and Reuse in a killable helper process so a timed-out attempt cannot keep writing after retry. Add FIFO lifecycle and squad Stage retry regression coverage.

Co-authored-by: multica-agent <github@multica.ai>

* fix(daemon): terminate Windows prepare process trees

Assign the pre-start helper to a kill-on-close Job Object before releasing its request, wait for all job members to exit on cancellation, and add a Windows runtime regression job.

Co-authored-by: multica-agent <github@multica.ai>

* ci: target Windows prepare tree regression

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: Bohan-J <bohan@devv.ai>
Co-authored-by: multica-agent <github@multica.ai>
2026-07-20 15:30:18 +08:00

40 lines
1.0 KiB
Go

//go:build !windows
package execenv
import (
"errors"
"os"
"os/exec"
"syscall"
)
type preparationProcessController struct{}
func newPreparationProcessController(cmd *exec.Cmd) (*preparationProcessController, error) {
if cmd.SysProcAttr == nil {
cmd.SysProcAttr = &syscall.SysProcAttr{}
}
cmd.SysProcAttr.Setpgid = true
return &preparationProcessController{}, nil
}
func (*preparationProcessController) attach(_ *exec.Cmd) error { return nil }
func (*preparationProcessController) stop(cmd *exec.Cmd) error {
if cmd.Process == nil {
return os.ErrProcessDone
}
// Kill the helper and any CLI it spawned. After SIGKILL is pending, a
// helper blocked in a kernel filesystem call cannot return to Go and
// perform another write when that call eventually unblocks.
err := syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
if errors.Is(err, syscall.ESRCH) {
return nil
}
return err
}
func (*preparationProcessController) finish() error { return nil }
func (*preparationProcessController) close() {}