Retrieving the caught signal within a handler

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Retrieving the caught signal within a handler

Joel Reymont
Is there a way to retrieve the signal within the signal handler?

I would like to know the signal that I caught.

        Thanks, Joel

--
http://wagerlabs.com/





_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving the caught signal within a handler

Bulat Ziganshin
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:[hidden email]



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving the caught signal within a handler

Joel Reymont
Thanks Bulat! This is what I ended up doing before you posted.
Sometimes just the mere fact of asking makes you come up with a  
solution.
I use #haskell for that alot :-).

On Dec 6, 2005, at 4:17 PM, Bulat Ziganshin wrote:

> 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)

--
http://wagerlabs.com/





_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving the caught signal within a handler

John Meacham
In reply to this post by Bulat Ziganshin
On a related note, it would be nice if we could get at the information
in the siginfo_t structure which can be read about in sigaction(2).
        John

--
John Meacham - ?repetae.net?john?
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe