github.com/stevenmatthewt/agent@v3.5.4+incompatible/bootstrap/shell/signal.go (about) 1 // +build !windows 2 3 package shell 4 5 import ( 6 "errors" 7 "os" 8 "os/exec" 9 "syscall" 10 ) 11 12 func signalProcess(cmd *exec.Cmd, sig os.Signal) error { 13 if cmd.Process == nil { 14 return errors.New("Process doesn't exist yet") 15 } 16 17 // If possible, send to the process group (linux/darwin/bsd) 18 if ssig, ok := sig.(syscall.Signal); ok { 19 return syscall.Kill(-cmd.Process.Pid, ssig) 20 } 21 22 return cmd.Process.Signal(sig) 23 }