summaryrefslogtreecommitdiff
path: root/vendor/github.com/sevlyar/go-daemon/lock_file_solaris.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/sevlyar/go-daemon/lock_file_solaris.go')
-rw-r--r--vendor/github.com/sevlyar/go-daemon/lock_file_solaris.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/github.com/sevlyar/go-daemon/lock_file_solaris.go b/vendor/github.com/sevlyar/go-daemon/lock_file_solaris.go
new file mode 100644
index 0000000..313dca0
--- /dev/null
+++ b/vendor/github.com/sevlyar/go-daemon/lock_file_solaris.go
@@ -0,0 +1,40 @@
+// +build solaris
+
+package daemon
+
+import (
+ "io"
+ "syscall"
+)
+
+func lockFile(fd uintptr) error {
+ lockInfo := syscall.Flock_t{
+ Type: syscall.F_WRLCK,
+ Whence: io.SeekStart,
+ Start: 0,
+ Len: 0,
+ }
+ if err := syscall.FcntlFlock(fd, syscall.F_SETLK, &lockInfo); err != nil {
+ if err == syscall.EAGAIN {
+ err = ErrWouldBlock
+ }
+ return err
+ }
+ return nil
+}
+
+func unlockFile(fd uintptr) error {
+ lockInfo := syscall.Flock_t{
+ Type: syscall.F_UNLCK,
+ Whence: io.SeekStart,
+ Start: 0,
+ Len: 0,
+ }
+ if err := syscall.FcntlFlock(fd, syscall.F_GETLK, &lockInfo); err != nil {
+ if err == syscall.EAGAIN {
+ err = ErrWouldBlock
+ }
+ return err
+ }
+ return nil
+}