--
-----------------------------------------------------------------------------
+#include "config.h"
+
module System.Posix.Signals (
+#ifndef mingw32_TARGET_OS
-- * The Signal type
Signal,
backgroundWrite, sigTTOU,
userDefinedSignal1, sigUSR1,
userDefinedSignal2, sigUSR2,
+#if HAVE_SIGPOLL
pollableEvent, sigPOLL,
+#endif
profilingTimerExpired, sigPROF,
badSystemCall, sigSYS,
breakpointTrap, sigTRAP,
-- sigaltstack()
-- sighold, sigignore, sigpause, sigrelse, sigset
-- siginterrupt
-
+#endif
) where
#include "Signals.h"
import Foreign.C
import System.IO.Unsafe
import System.Posix.Types
-import GHC.Posix
+import System.Posix.Internals
+
+#ifndef mingw32_TARGET_OS
+-- WHOLE FILE...
-- -----------------------------------------------------------------------------
-- Specific signals
foreign import ccall "__hsposix_SIGTTOU" sigTTOU :: CInt
foreign import ccall "__hsposix_SIGUSR1" sigUSR1 :: CInt
foreign import ccall "__hsposix_SIGUSR2" sigUSR2 :: CInt
+#if HAVE_SIGPOLL
foreign import ccall "__hsposix_SIGPOLL" sigPOLL :: CInt
+#endif
foreign import ccall "__hsposix_SIGPROF" sigPROF :: CInt
foreign import ccall "__hsposix_SIGSYS" sigSYS :: CInt
foreign import ccall "__hsposix_SIGTRAP" sigTRAP :: CInt
userDefinedSignal2 :: Signal
userDefinedSignal2 = sigUSR2
+#if HAVE_SIGPOLL
pollableEvent :: Signal
pollableEvent = sigPOLL
+#endif
profilingTimerExpired :: Signal
profilingTimerExpired = sigPROF
| Ignore
-- not yet: | Hold
| Catch (IO ())
+ | CatchOnce (IO ())
installHandler :: Signal
-> Handler
rc <- case handler of
Default -> stg_sig_install int (#const STG_SIG_DFL) p_sp mask
Ignore -> stg_sig_install int (#const STG_SIG_IGN) p_sp mask
- Catch m -> do sptr <- newStablePtr m
- poke p_sp sptr
- stg_sig_install int (#const STG_SIG_HAN) p_sp mask
+ Catch m -> install'' m p_sp mask int (#const STG_SIG_HAN)
+ CatchOnce m -> install'' m p_sp mask int (#const STG_SIG_RST)
case rc of
(#const STG_SIG_DFL) -> return Default
(#const STG_SIG_IGN) -> return Ignore
(#const STG_SIG_ERR) -> throwErrno "installHandler"
(#const STG_SIG_HAN) -> do
- osptr <- peek p_sp
- m <- deRefStablePtr osptr
+ m <- peekHandler p_sp
return (Catch m)
+ (#const STG_SIG_RST) -> do
+ m <- peekHandler p_sp
+ return (CatchOnce m)
+
+ install'' m p_sp mask int reset = do
+ sptr <- newStablePtr m
+ poke p_sp sptr
+ stg_sig_install int reset p_sp mask
+
+ peekHandler p_sp = do
+ osptr <- peek p_sp
+ deRefStablePtr osptr
foreign import ccall unsafe
stg_sig_install :: CInt -> CInt -> Ptr (StablePtr (IO ())) -> Ptr CSigset
foreign import ccall unsafe "__hsposix_SIG_BLOCK" c_SIG_BLOCK :: CInt
foreign import ccall unsafe "__hsposix_SIG_SETMASK" c_SIG_SETMASK :: CInt
foreign import ccall unsafe "__hsposix_SIG_UNBLOCK" c_SIG_UNBLOCK :: CInt
+
+#endif /* mingw32_TARGET_OS */
+