diff options
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Daemon.hs | 18 | ||||
-rw-r--r-- | Utility/WebApp.hs | 12 |
2 files changed, 16 insertions, 14 deletions
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs index 16245268e..185ea3e68 100644 --- a/Utility/Daemon.hs +++ b/Utility/Daemon.hs @@ -34,16 +34,22 @@ daemonize logfd pidfile changedirectory a = do when changedirectory $ setCurrentDirectory "/" nullfd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags - _ <- redir nullfd stdInput - mapM_ (redir logfd) [stdOutput, stdError] - closeFd logfd + redir nullfd stdInput + redirLog logfd a out - redir newh h = do - closeFd h - dupTo newh h out = exitImmediately ExitSuccess +redirLog :: Fd -> IO () +redirLog logfd = do + mapM_ (redir logfd) [stdOutput, stdError] + closeFd logfd + +redir :: Fd -> Fd -> IO () +redir newh h = do + closeFd h + void $ dupTo newh h + {- Locks the pid file, with an exclusive, non-blocking lock. - Writes the pid to the file, fully atomically. - Fails if the pid file is already locked by another process. -} diff --git a/Utility/WebApp.hs b/Utility/WebApp.hs index 51300c9cf..c6aae9db5 100644 --- a/Utility/WebApp.hs +++ b/Utility/WebApp.hs @@ -40,16 +40,12 @@ import Control.Concurrent localhost :: String localhost = "localhost" -{- Runs a web browser on a given url. - - - - Note: The url *will* be visible to an attacker. -} -runBrowser :: String -> (Maybe [(String, String)]) -> IO Bool -runBrowser url env = boolSystemEnv cmd [Param url] env - where +{- Command to use to run a web browser. -} +browserCommand :: FilePath #ifdef darwin_HOST_OS - cmd = "open" +browserCommand = "open" #else - cmd = "xdg-open" +browserCommand = "xdg-open" #endif {- Binds to a socket on localhost, and runs a webapp on it. |