diff options
| -rw-r--r-- | lockfiles.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lockfiles.lua b/lockfiles.lua index e223e10..075150d 100644 --- a/lockfiles.lua +++ b/lockfiles.lua @@ -45,6 +45,15 @@ do end assert(vis_pid) +local function pid_lives(pid) + local tst = io.open('/proc/' .. pid .. '/stat') + if tst then + tst:close() + return true + end + return false +end + -- returns PID owning lock (possibly vis_pid) local function create_lock_file(lock_dir, lfile_path) local lock_pid @@ -52,7 +61,9 @@ local function create_lock_file(lock_dir, lfile_path) if lock_file then lock_pid = lock_file:read('*n') lock_file:close() - return lock_pid + if lock_pid == vis_pid or pid_lives(lock_pid) then + return lock_pid + end end -- create the lock file with our pid |
