2 * Console control handler support.
5 #ifndef __CONSOLEHANDLER_H__
6 #define __CONSOLEHANDLER_H__
9 * Console control handlers lets an application handle Ctrl+C, Ctrl+Break etc.
10 * in Haskell under Win32. Akin to the Unix signal SIGINT.
12 * The API offered by ConsoleHandler.h is identical to that of the signal handling
13 * code (which isn't supported under win32.) Unsurprisingly, the underlying impl
14 * is derived from the signal handling code also.
18 * Function: signals_pending()
20 * Used by the RTS to check whether new signals have been 'recently' reported.
21 * If so, the RTS arranges for the delivered signals to be handled by
22 * de-queueing them from their table, running the associated Haskell
25 extern StgInt stg_pending_events;
27 #define signals_pending() ( stg_pending_events > 0)
30 * Function: anyUserHandlers()
32 * Used by the Scheduler to decide whether its worth its while to stick
33 * around waiting for an external signal when there are no threads
34 * runnable. A console handler is used to handle termination events (Ctrl+C)
35 * and isn't considered a 'user handler'.
37 #define anyUserHandlers() (rtsFalse)
40 * Function: startSignalHandlers()
42 * Run the handlers associated with the queued up console events. Console
43 * event delivery is blocked for the duration of this call.
45 extern void startSignalHandlers(Capability *cap);
48 * Function: handleSignalsInThisThread()
50 * Have current (OS) thread assume responsibility of handling console events/signals.
51 * Currently not used (by the console event handling code.)
53 extern void handleSignalsInThisThread(void);
56 * Function: rts_waitConsoleHandlerCompletion()
58 * Esoteric entry point used by worker thread that got woken
59 * up as part Ctrl-C delivery.
61 extern int rts_waitConsoleHandlerCompletion(void);
63 #endif /* __CONSOLEHANDLER_H__ */