//go:build linux || darwin package session import ( "errors" "os" "syscall" ) const supportsWriterLease = true func openLeaseFile(path string) (*os.File, error) { fd, err := syscall.Open(path, syscall.O_CREAT|syscall.O_RDWR|syscall.O_CLOEXEC|syscall.O_NOFOLLOW, 0600) if err != nil { return nil, err } return os.NewFile(uintptr(fd), path), nil } func lockLeaseFile(f *os.File) error { return syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB) } func leaseWouldBlock(err error) bool { return errors.Is(err, syscall.EWOULDBLOCK) || errors.Is(err, syscall.EAGAIN) }