packages feed

direct-daemonize 1.0 → 3.0

raw patch · 3 files changed

+36/−30 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- System.Daemonize: daemonFileDescriptorsToLeaveOpen :: DaemonOptions -> [Fd]
- System.Daemonize: daemonShouldCloseAllStreams :: DaemonOptions -> Bool
+ System.Daemonize: daemonShouldCloseStandardStreams :: DaemonOptions -> Bool
- System.Daemonize: DaemonOptions :: Bool -> Bool -> Bool -> [Fd] -> Bool -> Maybe String -> Maybe String -> DaemonOptions
+ System.Daemonize: DaemonOptions :: Bool -> Bool -> Bool -> Bool -> Maybe String -> Maybe String -> DaemonOptions
- System.Daemonize: daemonize :: DaemonOptions -> IO ()
+ System.Daemonize: daemonize :: DaemonOptions -> IO () -> IO ()

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2009 Dan Knapp+Copyright (c) 2012 Irene Knapp  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
System/Daemonize.hs view
@@ -9,15 +9,17 @@ import qualified Control.Exception as Exception import Foreign import Foreign.C+import System.Exit import System.IO import qualified System.Posix as POSIX +import Control.Concurrent + data DaemonOptions = DaemonOptions {     daemonShouldChangeDirectory :: Bool,     daemonShouldRedirectStandardStreams :: Bool,-    daemonShouldCloseAllStreams :: Bool,-    daemonFileDescriptorsToLeaveOpen :: [POSIX.Fd],+    daemonShouldCloseStandardStreams :: Bool,     daemonShouldIgnoreSignals :: Bool,     daemonUserToChangeTo :: Maybe String,     daemonGroupToChangeTo :: Maybe String@@ -28,8 +30,7 @@ defaultDaemonOptions = DaemonOptions {                          daemonShouldChangeDirectory = True,                          daemonShouldRedirectStandardStreams = False,-                         daemonShouldCloseAllStreams = True,-                         daemonFileDescriptorsToLeaveOpen = [],+                         daemonShouldCloseStandardStreams = True,                          daemonShouldIgnoreSignals = True,                          daemonUserToChangeTo = Nothing,                          daemonGroupToChangeTo = Nothing@@ -39,8 +40,8 @@ foreign import ccall "daemon" c_daemon :: CInt -> CInt -> IO CInt  -daemonize :: DaemonOptions -> IO ()-daemonize options = do+daemonize :: DaemonOptions -> IO () -> IO ()+daemonize options action = do   case daemonGroupToChangeTo options of     Nothing -> return ()     Just groupName -> do@@ -51,6 +52,12 @@     Just userName -> do       userEntry <- POSIX.getUserEntryForName userName       POSIX.setUserID $ POSIX.userID userEntry+  _ <- POSIX.forkProcess $ daemonize' options action+  POSIX.exitImmediately ExitSuccess+++daemonize' :: DaemonOptions -> IO () -> IO ()+daemonize' options action = do   let c_shouldChangeDirectory         = if daemonShouldChangeDirectory options             then 0@@ -69,18 +76,7 @@       POSIX.installHandler POSIX.sigTSTP POSIX.Ignore Nothing       return ()     else return ()-  if daemonShouldCloseAllStreams options-    then do-      mapM hClose [stdin, stdout, stderr]-      let closeLoop i | i == 65536 = return ()-                      | otherwise = do-                          if not $ elem (POSIX.Fd i)-                                        $ daemonFileDescriptorsToLeaveOpen options-                            then Exception.catch (POSIX.closeFd $ POSIX.Fd i)-                                   (\e -> do-                                      return (e :: Exception.SomeException)-                                      return ())-                            else return ()-                          closeLoop $ i + 1-      closeLoop 0+  if daemonShouldCloseStandardStreams options+    then mapM_ hClose [stdin, stdout, stderr]     else return ()+  action
direct-daemonize.cabal view
@@ -1,22 +1,32 @@ name: direct-daemonize-version: 1.0-cabal-version: >= 1.2+version: 3.0+cabal-version: >= 1.12 build-type: Simple license: BSD3 license-file: LICENSE-copyright: Copyright (c) 2009 Dan Knapp-author: Dan Knapp-maintainer: dankna@gmail.com-homepage: http://dankna.com/software/-bug-reports: http://dankna.com/issues/create/+copyright: Copyright (c) 2012 Irene Knapp+author: Irene Knapp <ireney.knapp@gmail.com>+maintainer: ireney.knapp@gmail.com+homepage: http://ireneknapp.com/software/+bug-reports: http://ireneknapp.com/issues/create/ category: System synopsis: Library to switch to daemon mode using built-in OS facilities. description:   This package is a wrapper around the daemon() function on BSD-like Unices,-  including Mac OS X and glibc-based Linux distributions.  It does not function on-  other systems.+  including Mac OS X and glibc-based Linux distributions.  It does not function+  on other systems.+  +  Version 3.0 cleans up the parameters structure.+  +  Version 2.0 fixes compatibility problems with the threaded GHC runtime.+  Doing this required two non-backwards-compatible API changes.  First, the daemonize function now takes an action to perform as a daemon, and never+  returns.  Second, the functionality of closing all open files has been+  removed, as it caused crashes.  As a substitute, the option of closing only+  the three standard streams has been added and made the default.  Library   exposed-modules: System.Daemonize   build-depends: base >= 4.1 && < 5,                  unix >= 2.4.0.1+  default-language: Haskell2010+