mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
util.signal: Wrap signalfd in an userdatum for gc handling etc
This commit is contained in:
parent
49c296360d
commit
761643abcc
2 changed files with 63 additions and 9 deletions
|
@ -1147,12 +1147,13 @@ end
|
|||
local hook_signal;
|
||||
if have_signal and signal.signalfd then
|
||||
local function dispatch(self)
|
||||
return self:on("signal", signal.signalfd_read(self:getfd()));
|
||||
return self:on("signal", self.conn:read());
|
||||
end
|
||||
|
||||
function hook_signal(signum, cb)
|
||||
local watch = watchfd(signal.signalfd(signum), dispatch);
|
||||
watch.listeners = { onsignal = cb };
|
||||
watch.close = nil; -- revert to default
|
||||
return watch;
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue