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
13 * signal handling code (which isn't supported under win32.)
14 * Unsurprisingly, the underlying impl is derived from the signal
18 #if !defined(THREADED_RTS)
20 * under THREADED_RTS, console events are passed to the IO manager
21 * thread, which starts up the handler. See ThrIOManager.c.
25 * Function: signals_pending()
27 * Used by the RTS to check whether new signals have been 'recently' reported.
28 * If so, the RTS arranges for the delivered signals to be handled by
29 * de-queueing them from their table, running the associated Haskell
32 extern StgInt stg_pending_events;
34 #define signals_pending() ( stg_pending_events > 0)
37 * Function: anyUserHandlers()
39 * Used by the Scheduler to decide whether its worth its while to stick
40 * around waiting for an external signal when there are no threads
41 * runnable. A console handler is used to handle termination events (Ctrl+C)
42 * and isn't considered a 'user handler'.
44 #define anyUserHandlers() (rtsFalse)
47 * Function: startSignalHandlers()
49 * Run the handlers associated with the queued up console events. Console
50 * event delivery is blocked for the duration of this call.
52 extern void startSignalHandlers(Capability *cap);
55 * Function: handleSignalsInThisThread()
57 * Have current (OS) thread assume responsibility of handling console events/signals.
58 * Currently not used (by the console event handling code.)
60 extern void handleSignalsInThisThread(void);
63 * Function: rts_waitConsoleHandlerCompletion()
65 * Esoteric entry point used by worker thread that got woken
66 * up as part Ctrl-C delivery.
68 extern int rts_waitConsoleHandlerCompletion(void);
70 #endif /* THREADED_RTS */
72 #endif /* __CONSOLEHANDLER_H__ */