aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-10-28 09:00:41 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2024-10-28 09:00:41 +0100
commit77706bcb80c889cb72c1be11c1cd7d32d284039c (patch)
tree6d39db092b266a3a95ba4107f201032bf86ee318 /init.lua
parent2a955d6bb5b3cee3f17c77f32a997e4710e97e27 (diff)
downloadvis-inotify-main.tar.gz
vis-inotify-main.zip
do not recreate watches after the QUIT event was receivedHEADmain
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 03ceda8..01b2ffa 100644
--- a/init.lua
+++ b/init.lua
@@ -22,6 +22,9 @@ if not os.execute('type inotifywait >/dev/null 2>/dev/null') then
return {}
end
+-- vis is exiting to not recreate watches
+local exiting = false
+
-- We have to keep the handles to our communicate processes otherwise
-- vis will terminate them.
local watches = {} -- luacheck: ignore watches
@@ -41,7 +44,7 @@ local function _add_watch(file, func, mode, cmd_options)
if event == 'EXIT' or event == 'SIGNAL' then
if event == 'EXIT' then
- if mode == 'recreate' then
+ if mode == 'recreate' and not exiting then
-- recreate the watch
watches[file] = nil
watches[file] = vis:communicate(file, cmd)
@@ -72,6 +75,7 @@ M.add_recreate_watch = function(file, func, cmd_options)
end
vis.events.subscribe(vis.events.QUIT, function()
+ exiting = true
-- Terminate all watches
for k, _ in pairs(watches) do watches[k] = nil end
end)