Files
gost-x/plugin/process_linux.go
T
ginuerzh f70b114578 plugin: manage external plugin subprocess lifecycle
Add Command []string to PluginConfig and a new x/plugin package that
spawns plugin subprocesses (deduplicated by argv) and terminates them
on Shutdown. Linux uses Pdeathsig, Windows a kill-on-close job object,
so children follow an abrupt parent exit.

Wire Spawn into every config/parsing plugin constructor.
2026-09-07 17:40:20 +08:00

20 lines
413 B
Go

//go:build linux
package plugin
import (
"os/exec"
"syscall"
)
// prepare arranges for the child to receive SIGTERM when the parent process
// dies, including an abrupt exit (panic, kill -9). It uses prctl(PR_SET_PDEATHSIG).
func prepare(cmd *exec.Cmd) {
if cmd.SysProcAttr == nil {
cmd.SysProcAttr = &syscall.SysProcAttr{}
}
cmd.SysProcAttr.Pdeathsig = syscall.SIGTERM
}
func attach(cmd *exec.Cmd) {}