]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/unix/app.h | |
3 | // Purpose: wxAppConsole implementation for Unix | |
4 | // Author: Lukasz Michalski | |
5 | // Created: 28/01/2005 | |
6 | // Copyright: (c) Lukasz Michalski | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | //Ensure that sigset_t is being defined | |
11 | #include <signal.h> | |
12 | ||
13 | class wxFDIODispatcher; | |
14 | class wxFDIOHandler; | |
15 | class wxWakeUpPipe; | |
16 | ||
17 | // wxApp subclass implementing event processing for console applications | |
18 | class WXDLLIMPEXP_BASE wxAppConsole : public wxAppConsoleBase | |
19 | { | |
20 | public: | |
21 | wxAppConsole(); | |
22 | virtual ~wxAppConsole(); | |
23 | ||
24 | // override base class initialization | |
25 | virtual bool Initialize(int& argc, wxChar** argv); | |
26 | ||
27 | ||
28 | // Unix-specific: Unix signal handling | |
29 | // ----------------------------------- | |
30 | ||
31 | // type of the function which can be registered as signal handler: notice | |
32 | // that it isn't really a signal handler, i.e. it's not subject to the | |
33 | // usual signal handlers constraints, because it is called later from | |
34 | // CheckSignal() and not when the signal really occurs | |
35 | typedef void (*SignalHandler)(int); | |
36 | ||
37 | // Set signal handler for the given signal, SIG_DFL or SIG_IGN can be used | |
38 | // instead of a function pointer | |
39 | // | |
40 | // Return true if handler was installed, false on error | |
41 | bool SetSignalHandler(int signal, SignalHandler handler); | |
42 | ||
43 | // Check if any Unix signals arrived since the last call and execute | |
44 | // handlers for them | |
45 | void CheckSignal(); | |
46 | ||
47 | // Register the signal wake up pipe with the given dispatcher. | |
48 | // | |
49 | // This is used by wxExecute(wxEXEC_NOEVENTS) implementation only. | |
50 | // | |
51 | // The pointer to the handler used for processing events on this descriptor | |
52 | // is returned so that it can be deleted when we no longer needed it. | |
53 | wxFDIOHandler* RegisterSignalWakeUpPipe(wxFDIODispatcher& dispatcher); | |
54 | ||
55 | private: | |
56 | // signal handler set up by SetSignalHandler() for all signals we handle, | |
57 | // it just adds the signal to m_signalsCaught -- the real processing is | |
58 | // done later, when CheckSignal() is called | |
59 | static void HandleSignal(int signal); | |
60 | ||
61 | ||
62 | // signals for which HandleSignal() had been called (reset from | |
63 | // CheckSignal()) | |
64 | sigset_t m_signalsCaught; | |
65 | ||
66 | // the signal handlers | |
67 | WX_DECLARE_HASH_MAP(int, SignalHandler, wxIntegerHash, wxIntegerEqual, SignalHandlerHash); | |
68 | SignalHandlerHash m_signalHandlerHash; | |
69 | ||
70 | // pipe used for wake up signal handling: if a signal arrives while we're | |
71 | // blocking for input, writing to this pipe triggers a call to our CheckSignal() | |
72 | wxWakeUpPipe *m_signalWakeUpPipe; | |
73 | }; |