fix build with unix-2.8.0

Changed the parameters to openFd. So needed to add a small wrapper
library to keep supporting older versions as well.
This commit is contained in:
Joey Hess 2023-08-01 18:41:27 -04:00
parent 4ef16f53ed
commit 68c9b08faf
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
12 changed files with 51 additions and 16 deletions

View file

@ -21,6 +21,7 @@ import Utility.PID
#ifndef mingw32_HOST_OS
import Utility.LogFile
import Utility.Env
import Utility.OpenFd
#else
import System.Win32.Process (terminateProcessById)
import Utility.LockFile
@ -49,7 +50,7 @@ daemonize cmd params openlogfd pidfile changedirectory a = do
maybe noop lockPidFile pidfile
a
_ -> do
nullfd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags
nullfd <- openFdWithMode (toRawFilePath "/dev/null") ReadOnly Nothing defaultFileFlags
redir nullfd stdInput
redirLog =<< openlogfd
environ <- getEnvironment
@ -95,9 +96,9 @@ foreground pidfile a = do
lockPidFile :: FilePath -> IO ()
lockPidFile pidfile = do
#ifndef mingw32_HOST_OS
fd <- openFd pidfile ReadWrite (Just stdFileMode) defaultFileFlags
fd <- openFdWithMode (toRawFilePath pidfile) ReadWrite (Just stdFileMode) defaultFileFlags
locked <- catchMaybeIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0)
fd' <- openFd newfile ReadWrite (Just stdFileMode) defaultFileFlags
fd' <- openFdWithMode (toRawFilePath newfile) ReadWrite (Just stdFileMode) defaultFileFlags
{ trunc = True }
locked' <- catchMaybeIO $ setLock fd' (WriteLock, AbsoluteSeek, 0, 0)
case (locked, locked') of
@ -132,7 +133,7 @@ checkDaemon :: FilePath -> IO (Maybe PID)
checkDaemon pidfile = bracket setup cleanup go
where
setup = catchMaybeIO $
openFd pidfile ReadOnly (Just stdFileMode) defaultFileFlags
openFdWithMode (toRawFilePath pidfile) ReadOnly (Just stdFileMode) defaultFileFlags
cleanup (Just fd) = closeFd fd
cleanup Nothing = return ()
go (Just fd) = catchDefaultIO Nothing $ do