1
0
Fork 0
mirror of https://github.com/Luzifer/duplicity-backup.git synced 2024-12-21 02:51:21 +00:00
duplicity-backup/vendor/github.com/nightlyone/lockfile/lockfile_unix.go

29 lines
431 B
Go
Raw Normal View History

2016-05-22 13:04:37 +00:00
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
package lockfile
import (
"os"
"syscall"
)
func isProcessAlive(p *os.Process) error {
err := p.Signal(os.Signal(syscall.Signal(0)))
if err == nil {
return nil
}
errno, ok := err.(syscall.Errno)
if !ok {
return ErrDeadOwner
}
switch errno {
case syscall.ESRCH:
return ErrDeadOwner
case syscall.EPERM:
return nil
default:
return err
}
}