github.com/go/docker@v1.12.0-rc2/utils/process_unix.go (about)

     1  // +build linux freebsd
     2  
     3  package utils
     4  
     5  import (
     6  	"syscall"
     7  )
     8  
     9  // IsProcessAlive returns true if process with a given pid is running.
    10  func IsProcessAlive(pid int) bool {
    11  	err := syscall.Kill(pid, syscall.Signal(0))
    12  	if err == nil || err == syscall.EPERM {
    13  		return true
    14  	}
    15  
    16  	return false
    17  }
    18  
    19  // KillProcess force-stops a process.
    20  func KillProcess(pid int) {
    21  	syscall.Kill(pid, syscall.SIGKILL)
    22  }