mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
4785f1a7ab
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
24 lines
417 B
Go
24 lines
417 B
Go
// +build linux freebsd darwin
|
|
|
|
package system
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// IsProcessAlive returns true if process with a given pid is running.
|
|
func IsProcessAlive(pid int) bool {
|
|
err := unix.Kill(pid, syscall.Signal(0))
|
|
if err == nil || err == unix.EPERM {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// KillProcess force-stops a process.
|
|
func KillProcess(pid int) {
|
|
unix.Kill(pid, unix.SIGKILL)
|
|
}
|