vendor/github.com/go-rod/rod/lib/launcher/os_unix.go

26 lines · 532 bytes

 1//go:build !windows
 2
 3package launcher
 4
 5import (
 6	"os/exec"
 7	"syscall"
 8
 9	"github.com/go-rod/rod/lib/launcher/flags"
10)
11
12func killGroup(pid int) {
13	_ = syscall.Kill(-pid, syscall.SIGKILL)
14}
15
16func (l *Launcher) osSetupCmd(cmd *exec.Cmd) {
17	if flags, has := l.GetFlags(flags.XVFB); has {
18		var command []string
19		// flags must append before cmd.Args
20		command = append(command, flags...)
21		command = append(command, cmd.Args...)
22
23		*cmd = *exec.Command("xvfb-run", command...)
24	}
25	cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
26}