summaryrefslogtreecommitdiff
path: root/tests/test-fcntl-lock-2.lua
blob: c5df7c4920280199f13c8663d62941606739a2f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- See LICENSE file for copyright and license details.
local l = require "luxio"

local fd, r, errno

fd, errno = l.open("test-lock-file", l.O_RDWR)
assert(fd >= 0)

t = {
   l_type = l.F_WRLCK,
   l_whence = l.SEEK_SET,
   l_start = 0,
   l_len = 4096
}

r, errno = l.fcntl(fd, l.F_GETLK, t)
print("fnctl: r,errno:", r, errno)
print("held by pid, waiting for unlock", t.l_pid)

t.l_type = l.F_WRLCK
r, errno = l.fcntl(fd, l.F_SETLKW, t)
print("fnctl: r,errno:", r, errno)