diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-15 20:41:28 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-15 20:42:53 -0400 |
commit | 96ac25094b04548812ec3d8e0860a62c9438b197 (patch) | |
tree | 729bc7f4f2773e949187f81d18ca45c8249fc272 /Utility/Daemon.hs | |
parent | 59abd787c948ef7a6bda3b62be9024212eb69a46 (diff) |
fix pid file writing
need to truncate, or part of previous longer pid may be left after writing
Diffstat (limited to 'Utility/Daemon.hs')
-rw-r--r-- | Utility/Daemon.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs index 3d2faed67..192340cef 100644 --- a/Utility/Daemon.hs +++ b/Utility/Daemon.hs @@ -44,7 +44,8 @@ daemonize logfd pidfile changedirectory a = do lockPidFile :: Bool -> IO () -> FilePath -> IO () lockPidFile write onfailure file = do - fd <- openFd file ReadWrite (Just stdFileMode) defaultFileFlags + fd <- openFd file ReadWrite (Just stdFileMode) + defaultFileFlags { trunc = write } locked <- catchMaybeIO $ setLock fd (locktype, AbsoluteSeek, 0, 0) case locked of Nothing -> onfailure |