mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
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.
20 lines
413 B
Go
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) {}
|