mirror of
https://github.com/Luzifer/duplicity-backup.git
synced 2024-12-21 02:51:21 +00:00
29 lines
431 B
Go
29 lines
431 B
Go
|
// +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
|
||
|
}
|
||
|
}
|