diff options
Diffstat (limited to 'Utility/LockFile/Posix.hs')
-rw-r--r-- | Utility/LockFile/Posix.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Utility/LockFile/Posix.hs b/Utility/LockFile/Posix.hs index 65ba328df..18d9e4fc1 100644 --- a/Utility/LockFile/Posix.hs +++ b/Utility/LockFile/Posix.hs @@ -12,6 +12,7 @@ module Utility.LockFile.Posix ( tryLockExclusive, checkLocked, getLockStatus, + LockStatus(..), dropLock, checkSaneLock, ) where @@ -66,8 +67,16 @@ openLockFile filemode lockfile = do checkLocked :: LockFile -> IO (Maybe Bool) checkLocked = maybe Nothing (Just . isJust) <$$> getLockStatus' -getLockStatus :: LockFile -> IO (Maybe ProcessID) -getLockStatus = fromMaybe Nothing <$$> getLockStatus' +data LockStatus = StatusUnLocked | StatusLockedBy ProcessID | StatusNoLockFile + deriving (Eq) + +getLockStatus :: LockFile -> IO LockStatus +getLockStatus lockfile = do + v <- getLockStatus' lockfile + return $ case v of + Nothing -> StatusNoLockFile + Just Nothing -> StatusUnLocked + Just (Just pid) -> StatusLockedBy pid getLockStatus' :: LockFile -> IO (Maybe (Maybe ProcessID)) getLockStatus' lockfile = go =<< catchMaybeIO open |