systemd 2.2.0 → 2.3.0
raw patch · 2 files changed
+12/−10 lines, 2 files
Files
- System/Systemd/Daemon/Fd.hs +11/−9
- systemd.cabal +1/−1
System/Systemd/Daemon/Fd.hs view
@@ -91,8 +91,16 @@ -- -- Equivalent to standard 'System.Systemd.Daemon.getActivatedSockets' getActivatedSockets :: IO (Maybe [Fd])-getActivatedSockets = fmap (fmap fst) <$> getActivatedSocketsWithNames+getActivatedSockets = runMaybeT $ do+ listenPid <- read <$> MaybeT (getEnv "LISTEN_PID")+ listenFDs <- read <$> MaybeT (getEnv "LISTEN_FDS") + myPid <- liftIO getProcessID+ guard $ listenPid == myPid++ mapM (\fd -> liftIO (setNonBlockIfNeeded fd) >> pure (Fd fd))+ [fdStart .. fdStart + listenFDs - 1]+ -- | Like 'getActivatedSockets', but also return the associated names. -- If a file descriptor has no associated name, it will be a generic -- one set by systemd.@@ -100,16 +108,10 @@ -- Equivalent to standard 'System.Systemd.Daemon.getActivatedSocketsWithNames' getActivatedSocketsWithNames :: IO (Maybe [(Fd, String)]) getActivatedSocketsWithNames = runMaybeT $ do- listenPid <- read <$> MaybeT (getEnv "LISTEN_PID")- listenFDs <- read <$> MaybeT (getEnv "LISTEN_FDS") listenFDNames <- MaybeT (getEnv "LISTEN_FDNAMES")-- myPid <- liftIO getProcessID- guard $ listenPid == myPid- let listenFDNames' = fmap BC.unpack $ BC.split ':' $ BC.pack listenFDNames- nonBlockFds <- mapM (\fd -> liftIO (setNonBlockIfNeeded fd) >> pure (Fd fd))- [fdStart .. fdStart + listenFDs - 1]++ nonBlockFds <- MaybeT getActivatedSockets guard $ length nonBlockFds == length listenFDNames' return $ zip nonBlockFds listenFDNames'
systemd.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: systemd-version: 2.2.0+version: 2.3.0 synopsis: Systemd facilities (Socket activation, Notify) description: A module for Systemd facilities. homepage: https://github.com/erebe/systemd