Commit 6ff1e84b authored by stolz's avatar stolz

[project @ 2002-12-05 14:20:55 by stolz]

Add SA_RESETHAND (aka SA_ONESHOT) support.
Requested by: John Meacham

> module Main where

> import System.Posix.Signals

> main = do
>   installHandler sigUSR1 (Catch (print "usr1")) Nothing
>   installHandler sigUSR2 (CatchOnce (print "usr2")) Nothing
>   _ <- getLine
>   return ()
parent 1ca2417e
/* -----------------------------------------------------------------------------
* $Id: Signals.h,v 1.1 2002/09/06 14:34:14 simonmar Exp $
* $Id: Signals.h,v 1.2 2002/12/05 14:20:55 stolz Exp $
*
* (c) The GHC Team, 1998-2002
*
......@@ -14,6 +14,7 @@
#define STG_SIG_IGN (-2)
#define STG_SIG_ERR (-3)
#define STG_SIG_HAN (-4)
#define STG_SIG_RST (-5)
extern int stg_sig_install (int, int, StgStablePtr *, void *);
......
/* -----------------------------------------------------------------------------
* $Id: Signals.c,v 1.29 2002/09/17 12:11:45 simonmar Exp $
* $Id: Signals.c,v 1.30 2002/12/05 14:20:55 stolz Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -228,9 +228,13 @@ stg_sig_install(int sig, int spi, StgStablePtr *handler, void *mask)
break;
case STG_SIG_HAN:
case STG_SIG_RST:
handlers[sig] = (StgInt)*handler;
sigaddset(&userSignals, sig);
action.sa_handler = generic_handler;
if (spi == STG_SIG_RST) {
action.sa_flags = SA_RESETHAND;
}
n_haskell_handlers++;
break;
......@@ -243,7 +247,7 @@ stg_sig_install(int sig, int spi, StgStablePtr *handler, void *mask)
else
sigemptyset(&action.sa_mask);
action.sa_flags = sig == SIGCHLD && nocldstop ? SA_NOCLDSTOP : 0;
action.sa_flags |= sig == SIGCHLD && nocldstop ? SA_NOCLDSTOP : 0;
if (sigaction(sig, &action, NULL) ||
sigprocmask(SIG_SETMASK, &osignals, NULL))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment