module Program.Mighty.Signal (
  -- * Signals
    sigStop
  , sigReload
  , sigRetire
  , sigInfo
  -- * Signal handling
  , setHandler
  ) where

import Control.Monad
import System.Posix

----------------------------------------------------------------

-- | The signal to stop Mighty.
sigStop :: Signal
sigStop :: Signal
sigStop   = Signal
sigTERM

-- | The signal to reload a configration file.
sigReload :: Signal
sigReload :: Signal
sigReload = Signal
sigHUP

-- | The signal to top accepting new connections and to finish current connections.
sigRetire :: Signal
sigRetire :: Signal
sigRetire = Signal
sigQUIT

-- | The signal to get information from Mighty.
sigInfo :: Signal
sigInfo :: Signal
sigInfo   = Signal
sigUSR2

----------------------------------------------------------------

-- | Setting 'Handler' for 'Signal'.
setHandler :: Signal -> Handler -> IO ()
setHandler :: Signal -> Handler -> IO ()
setHandler Signal
sig Handler
func = IO Handler -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO Handler -> IO ()) -> IO Handler -> IO ()
forall a b. (a -> b) -> a -> b
$ Signal -> Handler -> Maybe SignalSet -> IO Handler
installHandler Signal
sig Handler
func Maybe SignalSet
forall a. Maybe a
Nothing