github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/utils/lockfile/lockfile_other.go (about)

     1  //go:build !windows
     2  // +build !windows
     3  
     4  package lockfile
     5  
     6  import (
     7  	"os"
     8  	"syscall"
     9  )
    10  
    11  func LockFile(file *os.File) error {
    12  	return syscall.Flock(int(file.Fd()), syscall.LOCK_EX|syscall.LOCK_NB)
    13  }