Revision a4c0fe1e

b/htools/Ganeti/Daemon.hs
196 196
  parseOpts cmd_args cmd options
197 197

  
198 198
-- * Daemon-related functions
199

  
199 200
-- | PID file mode.
200 201
pidFileMode :: FileMode
201 202
pidFileMode = unionFileModes ownerReadMode ownerWriteMode
202 203

  
204
-- | PID file open flags.
205
pidFileFlags :: OpenFileFlags
206
pidFileFlags = defaultFileFlags { noctty = True, trunc = False }
207

  
203 208
-- | Writes a PID file and locks it.
204 209
_writePidFile :: FilePath -> IO Fd
205 210
_writePidFile path = do
206
  fd <- createFile path pidFileMode
211
  fd <- openFd path ReadWrite (Just pidFileMode) pidFileFlags
207 212
  setLock fd (WriteLock, AbsoluteSeek, 0, 0)
208 213
  my_pid <- getProcessID
209 214
  _ <- fdWrite fd (show my_pid ++ "\n")

Also available in: Unified diff