fix pid file writing
need to truncate, or part of previous longer pid may be left after writing
This commit is contained in:
parent
59abd787c9
commit
96ac25094b
1 changed files with 2 additions and 1 deletions
|
@ -44,7 +44,8 @@ daemonize logfd pidfile changedirectory a = do
|
||||||
|
|
||||||
lockPidFile :: Bool -> IO () -> FilePath -> IO ()
|
lockPidFile :: Bool -> IO () -> FilePath -> IO ()
|
||||||
lockPidFile write onfailure file = do
|
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)
|
locked <- catchMaybeIO $ setLock fd (locktype, AbsoluteSeek, 0, 0)
|
||||||
case locked of
|
case locked of
|
||||||
Nothing -> onfailure
|
Nothing -> onfailure
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue