open-nomad/helper/testtask/testtask_unix.go

25 lines
593 B
Go
Raw Normal View History

//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
2019-01-10 15:04:34 +00:00
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
2019-01-08 23:34:02 +00:00
package testtask
import (
"fmt"
"os"
"strconv"
"syscall"
)
func executeProcessGroup(gid string) {
// pgrp <group_int> puts the pid in a new process group
grp, err := strconv.Atoi(gid)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to convert process group number %q: %v\n", gid, err)
os.Exit(1)
}
if err := syscall.Setpgid(0, grp); err != nil {
fmt.Fprintf(os.Stderr, "failed to set process group: %v\n", err)
os.Exit(1)
}
}