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

Safe Haskell | Safe
Language | Haskell2010

System.Process.PID1

Synopsis

- run :: FilePath -> [String] -> Maybe [(String, String)] -> IO a

# Documentation

run #

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