mirror of
https://github.com/reanimate/reanimate.git
synced 2026-09-11 16:12:20 +00:00
19 lines
549 B
Haskell
19 lines
549 B
Haskell
module Detach (detach) where
|
|
|
|
import Control.Concurrent
|
|
import Control.Monad
|
|
import System.Posix.IO
|
|
import System.Posix.Process (createSession, forkProcess)
|
|
|
|
detach :: IO () -> IO Bool
|
|
detach daemon = do
|
|
void $ forkProcess $ do
|
|
devnull <- openFd "/dev/null" ReadWrite defaultFileFlags
|
|
void $ dupTo devnull stdInput
|
|
void $ dupTo devnull stdOutput
|
|
void $ dupTo devnull stdError
|
|
closeFd devnull
|
|
void createSession
|
|
void $ forkProcess daemon
|
|
threadDelay (10^(6::Int))
|
|
return True
|