github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/pkg/system/process_unix.go (about) 1 // +build linux freebsd darwin 2 3 package system 4 5 import ( 6 "syscall" 7 8 "golang.org/x/sys/unix" 9 ) 10 11 // IsProcessAlive returns true if process with a given pid is running. 12 func IsProcessAlive(pid int) bool { 13 err := unix.Kill(pid, syscall.Signal(0)) 14 if err == nil || err == unix.EPERM { 15 return true 16 } 17 18 return false 19 } 20 21 // KillProcess force-stops a process. 22 func KillProcess(pid int) { 23 unix.Kill(pid, unix.SIGKILL) 24 }