2 * Console control handler support.
5 #ifndef WIN32_CONSOLEHANDLER_H
6 #define WIN32_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: rts_waitConsoleHandlerCompletion()
57 * Esoteric entry point used by worker thread that got woken
58 * up as part Ctrl-C delivery.
60 extern int rts_waitConsoleHandlerCompletion(void);
62 #endif /* THREADED_RTS */
64 #endif /* Win32_CONSOLEHANDLER_H */