github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/helper/testtask/testtask_unix.go (about)

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