pid1-0.1.2.0: Do signal handling and orphan reaping for Unix PID1 init processes

Safe Haskell | Safe
Language | Haskell2010

System.Process.PID1

Synopsis

- data RunOptions
- defaultRunOptions :: RunOptions
- getRunEnv :: RunOptions -> Maybe [(String, String)]
- getRunExitTimeoutSec :: RunOptions -> Int
- getRunGroup :: RunOptions -> Maybe String
- getRunUser :: RunOptions -> Maybe String
- getRunWorkDir :: RunOptions -> Maybe FilePath
- run :: FilePath -> [String] -> Maybe [(String, String)] -> IO a
- runWithOptions :: RunOptions -> FilePath -> [String] -> IO a
- setRunEnv :: [(String, String)] -> RunOptions -> RunOptions
- setRunExitTimeoutSec :: Int -> RunOptions -> RunOptions
- setRunGroup :: String -> RunOptions -> RunOptions
- setRunUser :: String -> RunOptions -> RunOptions
- setRunWorkDir :: FilePath -> RunOptions -> RunOptions

# Documentation

data RunOptions Source #

Holder for pid1 run options

Instances

Show RunOptions Source # |
Instance details Defined in System.Process.PID1 Methods showsPrec :: Int -> RunOptions -> ShowS Source # show :: RunOptions -> String Source # showList :: [RunOptions] -> ShowS Source #

defaultRunOptions :: RunOptions Source #

return default `RunOptions`

Since: 0.1.1.0

getRunEnv :: RunOptions -> Maybe [(String, String)] Source #

Get environment variable overrides for the given `RunOptions`

Since: 0.1.1.0

getRunExitTimeoutSec :: RunOptions -> Int Source #

Return the timeout (in seconds) timeout (in seconds) to wait for all child processes to exit after receiving SIGTERM or SIGINT signal

Since: 0.1.2.0

getRunGroup :: RunOptions -> Maybe String Source #

Get the process `setGroupID` group for the given `RunOptions`

Since: 0.1.1.0

getRunUser :: RunOptions -> Maybe String Source #

Get the process `setUserID` user for the given `RunOptions`

Since: 0.1.1.0

getRunWorkDir :: RunOptions -> Maybe FilePath Source #

Get the process current directory for the given `RunOptions`

Since: 0.1.1.0

run Source #

Arguments

:: FilePath | command to run
-> [String] | command line arguments
-> Maybe [(String, String)] | optional environment variable override, default is current env
-> IO a |

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 `exec` the given command.

This function will never exit: it will always terminate your process, unless some exception is thrown.

Since: 0.1.0.0

runWithOptions Source #

Arguments

:: RunOptions | run options
-> FilePath | command to run
-> [String] | command line arguments
-> IO a |

Variant of `run` 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).

Since: 0.1.1.0

setRunEnv :: [(String, String)] -> RunOptions -> RunOptions Source #

Set environment variable overrides for the given `RunOptions`

Since: 0.1.1.0

setRunExitTimeoutSec :: Int -> RunOptions -> RunOptions Source #

Set the timeout in seconds for the process reaper to wait for all child processes to exit after receiving SIGTERM or SIGINT signal

Since: 0.1.2.0

setRunGroup :: String -> RunOptions -> RunOptions Source #

Set the process `setGroupID` group for the given `RunOptions`

Since: 0.1.1.0

setRunUser :: String -> RunOptions -> RunOptions Source #

Set the process `setUserID` user for the given `RunOptions`

Since: 0.1.1.0

setRunWorkDir :: FilePath -> RunOptions -> RunOptions Source #

Set the process current directory for the given `RunOptions`

Since: 0.1.1.0