2019-06-27 11:30:45 +00:00
|
|
|
// +build darwin dragonfly freebsd linux netbsd openbsd plan9
|
2018-02-27 19:46:50 +00:00
|
|
|
|
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
func lockFile(fd uintptr) error {
|
|
|
|
err := syscall.Flock(int(fd), syscall.LOCK_EX|syscall.LOCK_NB)
|
|
|
|
if err == syscall.EWOULDBLOCK {
|
|
|
|
err = ErrWouldBlock
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func unlockFile(fd uintptr) error {
|
|
|
|
err := syscall.Flock(int(fd), syscall.LOCK_UN)
|
|
|
|
if err == syscall.EWOULDBLOCK {
|
|
|
|
err = ErrWouldBlock
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|