-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Using the sigals module on NetBSD seems to break file io in certain situations. After catching and handling a signal, an open file handle still works, but attempting to open it again later fails with EINTR regardless if the original handle was closed or not.
The following is my best attempt thus far for a minimal repoduction:
local cq = cqueues.new()
-- listener
local sl = signal.listen( signal.SIGHUP )
signal.block( signal.SIGHUP )
cq:wrap(function()
print( 'signal:', sl:wait(10) )
end)
-- open file
local f = io.open('./testfile', 'w')
assert(f:write("test data\n"))
assert(f:flush())
-- raise
cq:wrap(function()
signal.raise( signal.SIGHUP )
end)
for err in cq:errors(10) do
print('>', err)
end
-- IO on this file broken?
assert(io.open('./testfile', 'r'))
Using Lua 5.4.4, NetBSD/evbarm64 9.3, and cqueues 20200726, the output is consistently:
signal: 1
lua5.4: ./netbsd-signal-bug.lua:35: ./testfile: Interrupted system call
stack traceback:
[C]: in function 'assert'
./netbsd-signal-bug.lua:35: in main chunk
[C]: in ?
...whereas on Linux only 'signal: 1' is present.
I've not yet ruled out that this is a NetBSD bug and not cqueues; but maybe the kqueue isn't getting properly drained or similar. I'm still looking into it.