lock_unix.go 332 B

1234567891011121314151617
  1. // +build !windows
  2. package providers
  3. import (
  4. "syscall"
  5. )
  6. // lockFile acquires an exclusive lock on the file descriptor
  7. func lockFile(fd int) error {
  8. return syscall.Flock(fd, syscall.LOCK_EX)
  9. }
  10. // unlockFile releases the lock on the file descriptor
  11. func unlockFile(fd int) error {
  12. return syscall.Flock(fd, syscall.LOCK_UN)
  13. }