2017-01-24 15:09:23 +00:00
|
|
|
// +build linux darwin freebsd netbsd openbsd
|
|
|
|
|
|
|
|
package runner
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
2018-05-23 07:53:19 +00:00
|
|
|
var (
|
2017-01-24 15:09:23 +00:00
|
|
|
// DefaultUserDataTmpDir is the default directory path for created user
|
|
|
|
// data directories.
|
2018-05-23 07:53:19 +00:00
|
|
|
defaultUserDataTmpDir = "/tmp"
|
2017-01-24 15:09:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// KillProcessGroup is a Chrome command line option that will instruct the
|
|
|
|
// invoked child Chrome process to terminate when the parent process (ie, the
|
|
|
|
// Go application) dies.
|
|
|
|
//
|
|
|
|
// Note: sets exec.Cmd.SysProcAttr.Setpgid = true and does nothing on Windows.
|
|
|
|
func KillProcessGroup(m map[string]interface{}) error {
|
|
|
|
return CmdOpt(func(c *exec.Cmd) error {
|
|
|
|
if c.SysProcAttr == nil {
|
|
|
|
c.SysProcAttr = new(syscall.SysProcAttr)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.SysProcAttr.Setpgid = true
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})(m)
|
|
|
|
}
|