summaryrefslogtreecommitdiff
path: root/tests/test-fcntl-lock-1.lua
blob: cb2493e9dcae8d9704b7c150c6c4b855fe5344d0 (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.bit.bor(l.O_CREAT, l.O_RDWR), tonumber("600", 8))
print("open: fd,errno:", fd, errno)
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_SETLK, t)
print("fnctl: r,errno:", r, errno)
print("sleeping 10 seconds")
l.sleep(10)

l.unlink "test-lock-file"