Files
Reims-Go/internal/plugin/sidecarproc/job_other.go
T
千川白浪 9006e6d9a7
CI / verify (push) Canceled after 0s
CI / rolling-release (push) Canceled after 0s
refactor: 抽离 HostAPIService 并将 internal/plugin 拆分为四层无环子包 (#202)
2026-12-05 06:05:41 -07:00

52 lines
885 B
Go

//go:build !windows
package sidecarproc
import (
"os/exec"
"sync"
"syscall"
)
func ConfigureSidecarCmd(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}
func ConfigureDetachedVMProcess(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
}
func ConfigureNestedVMProcess(cmd *exec.Cmd) { ConfigureDetachedVMProcess(cmd) }
func ResumeVMProcess(int) error { return nil }
func IsBreakawayDenied(error) bool { return false }
type SidecarJob struct {
pgid int
closeOnce sync.Once
}
func NewSidecarJob(_ uintptr) (*SidecarJob, error) {
return &SidecarJob{}, nil
}
func (j *SidecarJob) Assign(pid int) error {
if j != nil {
j.pgid = pid
}
return nil
}
func (j *SidecarJob) Close() {
if j == nil {
return
}
j.closeOnce.Do(func() {
if j.pgid > 0 {
_ = syscall.Kill(-j.pgid, syscall.SIGKILL)
j.pgid = 0
}
})
}