Created
November 29, 2012 08:11
Revisions
-
jedy created this gist
Nov 29, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ package main import ( "fmt" "os" "syscall" "unsafe" ) func main() { k := struct { Type uint32 Whence uint32 Start uint64 Len uint64 Pid uint32 }{ syscall.F_WRLCK, uint32(os.SEEK_SET), 0, 10, 0, } f, err := os.OpenFile("x", os.O_RDWR, 0666) _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_SETLKW), uintptr(unsafe.Pointer(&k))) fmt.Println(errno) b := make([]byte, 1) os.Stdin.Read(b) }