mirror of
https://github.com/golang/sys.git
synced 2026-02-08 03:36:03 +03:00
AIX doesn't provide a flock() syscall, it was previously emulated in package syscall by using fcntl. This emulation was removed in CL 152397. Since unix.Flock wraps syscall.Flock, the build currently fails on aix without this change. Change-Id: Ie887619cd64ae009ea43f00c74e450a5b8f998ac Reviewed-on: https://go-review.googlesource.com/c/153938 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Clément Chigot <clement.chigot@atos.net> Reviewed-by: Ian Lance Taylor <iant@golang.org>
26 lines
594 B
Go
26 lines
594 B
Go
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
|
|
package unix_test
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func ExampleFlock() {
|
|
f, _ := os.Create("example.lock")
|
|
if err := unix.Flock(int(f.Fd()), unix.LOCK_EX); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
// Do work here that requires the lock. When finished, release the lock:
|
|
if err := unix.Flock(int(f.Fd()), unix.LOCK_UN); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|