Harden Harness runtime, persistence and execution for Hand

This commit is contained in:
sausheong committed 2026-09-09 22:55:55 +08:00
1 parent 09c30fe2d5
commit 0972eed3ea
164 files changed
+15912 -506

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
//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)
}