aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lockfiles.lua6
1 files 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()