diff options
author | Joey Hess <joey@kitenet.net> | 2014-05-14 14:26:28 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-05-14 14:26:28 -0400 |
commit | 2b89de6562469c7bee6ae8e78205012ef43396dc (patch) | |
tree | ad5804336698abe852551adc44704276fd6ae0cf /Utility/Daemon.hs | |
parent | 250035e1843bbcded9d45a45d043b6bfc8f1dc4f (diff) |
setsid when running webapp in foreground too
This avoids ssh prompting for passwords on stdin, ever.
It may also change other behavior of other programs, as there is no
controlling terminal now. However, setsid was already done when running the
assistant in daemon mode, so any behavior changes should not be really new.
Diffstat (limited to 'Utility/Daemon.hs')
-rw-r--r-- | Utility/Daemon.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Utility/Daemon.hs b/Utility/Daemon.hs index 2b62382ee..2a2e0e08a 100644 --- a/Utility/Daemon.hs +++ b/Utility/Daemon.hs @@ -56,6 +56,15 @@ daemonize logfd pidfile changedirectory a = do out = exitImmediately ExitSuccess #endif +{- To run an action that is normally daemonized in the forground. -} +foreground :: Fd -> Maybe FilePath -> IO () -> IO () +foreground logfd pidfile a = do + maybe noop lockPidFile pidfile + _ <- createSession + redirLog logfd + a + exitImmediately ExitSuccess + {- Locks the pid file, with an exclusive, non-blocking lock, - and leaves it locked on return. - |