github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/helper/testtask/testtask_unix.go (about)

     1  // +build darwin dragonfly freebsd linux netbsd openbsd solaris
     2  
     3  package testtask
     4  
     5  import (
     6  	"fmt"
     7  	"os"
     8  	"strconv"
     9  	"syscall"
    10  )
    11  
    12  func executeProcessGroup(gid string) {
    13  	// pgrp <group_int> puts the pid in a new process group
    14  	grp, err := strconv.Atoi(gid)
    15  	if err != nil {
    16  		fmt.Fprintf(os.Stderr, "failed to convert process group number %q: %v\n", gid, err)
    17  		os.Exit(1)
    18  	}
    19  	if err := syscall.Setpgid(0, grp); err != nil {
    20  		fmt.Fprintf(os.Stderr, "failed to set process group: %v\n", err)
    21  		os.Exit(1)
    22  	}
    23  }