mirror of
https://github.com/Luzifer/duplicity-backup.git
synced 2024-11-08 23:20:05 +00:00
28 lines
431 B
Go
28 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
|
|
}
|
|
}
|