-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Do signal handling and orphan reaping for Unix PID1 init processes
--   
--   Please see README.md or view Haddocks at
--   <a>https://www.stackage.org/package/pid1</a>
@package pid1
@version 0.1.2.0

module System.Process.PID1

-- | Holder for pid1 run options
data RunOptions

-- | return default <a>RunOptions</a>
defaultRunOptions :: RunOptions

-- | Get environment variable overrides for the given <a>RunOptions</a>
getRunEnv :: RunOptions -> Maybe [(String, String)]

-- | Return the timeout (in seconds) timeout (in seconds) to wait for all
--   child processes to exit after receiving SIGTERM or SIGINT signal
getRunExitTimeoutSec :: RunOptions -> Int

-- | Get the process <a>setGroupID</a> group for the given
--   <a>RunOptions</a>
getRunGroup :: RunOptions -> Maybe String

-- | Get the process <a>setUserID</a> user for the given <a>RunOptions</a>
getRunUser :: RunOptions -> Maybe String

-- | Get the process current directory for the given <a>RunOptions</a>
getRunWorkDir :: RunOptions -> Maybe FilePath

-- | Run the given command with specified arguments, with optional
--   environment variable override (default is to use the current process's
--   environment).
--   
--   This function will check if the current process has a process ID of 1.
--   If it does, it will install signal handlers for SIGTERM and SIGINT,
--   set up a loop to reap all orphans, spawn a child process, and when
--   that child dies, kill all other processes (first with a SIGTERM and
--   then a SIGKILL) and exit with the child's exit code.
--   
--   If this process is not PID1, then it will simply <tt>exec</tt> the
--   given command.
--   
--   This function will never exit: it will always terminate your process,
--   unless some exception is thrown.
run :: FilePath -> [String] -> Maybe [(String, String)] -> IO a

-- | Variant of <a>run</a> that runs a command, with optional environment
--   posix user/group and working directory (default is to use the current
--   process's user, group, environment, and current directory).
runWithOptions :: RunOptions -> FilePath -> [String] -> IO a

-- | Set environment variable overrides for the given <a>RunOptions</a>
setRunEnv :: [(String, String)] -> RunOptions -> RunOptions

-- | Set the timeout in seconds for the process reaper to wait for all
--   child processes to exit after receiving SIGTERM or SIGINT signal
setRunExitTimeoutSec :: Int -> RunOptions -> RunOptions

-- | Set the process <a>setGroupID</a> group for the given
--   <a>RunOptions</a>
setRunGroup :: String -> RunOptions -> RunOptions

-- | Set the process <a>setUserID</a> user for the given <a>RunOptions</a>
setRunUser :: String -> RunOptions -> RunOptions

-- | Set the process current directory for the given <a>RunOptions</a>
setRunWorkDir :: FilePath -> RunOptions -> RunOptions
instance GHC.Show.Show System.Process.PID1.RunOptions
