[Haskell-cafe] Retrieving the caught signal within a handler

Bulat Ziganshin bulatz at HotPOP.com
Tue Dec 6 11:17:46 EST 2005

Hello Joel,

Tuesday, December 06, 2005, 1:39:10 PM, you wrote:

JR> Is there a way to retrieve the signal within the signal handler?

JR> I would like to know the signal that I caught.

just pass signal number to the handler you installs :)

        installHandler sigPIPE Ignore Nothing
        flip mapM_ [sigINT, sigHUP, sigABRT, sigTERM] $ \sig -> do
          installHandler sig handler Nothing
              where handler = Catch $ exitWith (ExitFailure 1)

replace for example last line with

              where handler = Catch $ exitWith (ExitFailure sig)

Best regards,
 Bulat                            mailto:bulatz at HotPOP.com

More information about the Haskell-Cafe mailing list