From dce094a0c6730ae47d27e90a84d2f582aba42736 Mon Sep 17 00:00:00 2001 From: Alin Mr Date: Fri, 3 May 2024 11:08:09 +0000 Subject: lockfiles.lua: fix fd leak --- lockfiles.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lockfiles.lua b/lockfiles.lua index 9e120bd..d018bc9 100644 --- a/lockfiles.lua +++ b/lockfiles.lua @@ -53,10 +53,12 @@ local function create_lock_file(lock_dir, lfile_path) end -- create the lock file with our pid - if not io.open(lfile_path, 'w') then + lock_file = io.open(lfile_path, 'w') + if not lock_file then + -- retry, this time asserting success; first ensure directory exists assert(os.execute('mkdir -p "' .. lock_dir .. '"')) + lock_file = assert(io.open(lfile_path, 'w')) end - lock_file = assert(io.open(lfile_path, 'w')) lock_file:write(vis_pid) lock_file:close() -- cgit v1.2.3