gitlab.com/apertussolutions/u-root@v7.0.0+incompatible/cmds/core/kill/signaler_unix.go (about) 1 // Copyright 2016-2017 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "fmt" 9 "os" 10 "strconv" 11 "syscall" 12 ) 13 14 var defaultSignal = "-SIGTERM" 15 16 func kill(sig os.Signal, pids ...string) []error { 17 var errs []error 18 s := sig.(syscall.Signal) 19 for _, p := range pids { 20 pid, err := strconv.Atoi(p) 21 if err != nil { 22 errs = append(errs, fmt.Errorf("%v: arguments must be process or job IDS", p)) 23 continue 24 } 25 if err := syscall.Kill(pid, s); err != nil { 26 errs = append(errs, err) 27 } 28 29 } 30 return errs 31 }