2007-05-14 19:43:39 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/unix/app.h
|
|
|
|
// Purpose: wxAppConsole implementation for Unix
|
|
|
|
// Author: Lukasz Michalski
|
|
|
|
// Created: 28/01/2005
|
|
|
|
// Copyright: (c) Lukasz Michalski
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-05-26 10:14:16 -04:00
|
|
|
//Ensure that sigset_t is being defined
|
|
|
|
#include <signal.h>
|
|
|
|
|
2013-07-02 20:31:03 -04:00
|
|
|
class wxFDIODispatcher;
|
|
|
|
class wxFDIOHandler;
|
|
|
|
class wxWakeUpPipe;
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
// wxApp subclass implementing event processing for console applications
|
2007-06-04 09:39:23 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxAppConsole : public wxAppConsoleBase
|
2007-05-14 19:43:39 -04:00
|
|
|
{
|
|
|
|
public:
|
2013-07-02 20:31:03 -04:00
|
|
|
wxAppConsole();
|
|
|
|
virtual ~wxAppConsole();
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
// override base class initialization
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool Initialize(int& argc, wxChar** argv) wxOVERRIDE;
|
2007-05-14 19:43:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
// Unix-specific: Unix signal handling
|
|
|
|
// -----------------------------------
|
|
|
|
|
|
|
|
// type of the function which can be registered as signal handler: notice
|
|
|
|
// that it isn't really a signal handler, i.e. it's not subject to the
|
|
|
|
// usual signal handlers constraints, because it is called later from
|
|
|
|
// CheckSignal() and not when the signal really occurs
|
|
|
|
typedef void (*SignalHandler)(int);
|
|
|
|
|
|
|
|
// Set signal handler for the given signal, SIG_DFL or SIG_IGN can be used
|
|
|
|
// instead of a function pointer
|
|
|
|
//
|
|
|
|
// Return true if handler was installed, false on error
|
|
|
|
bool SetSignalHandler(int signal, SignalHandler handler);
|
|
|
|
|
|
|
|
// Check if any Unix signals arrived since the last call and execute
|
|
|
|
// handlers for them
|
|
|
|
void CheckSignal();
|
|
|
|
|
2013-07-02 20:31:03 -04:00
|
|
|
// Register the signal wake up pipe with the given dispatcher.
|
|
|
|
//
|
2013-07-02 20:32:16 -04:00
|
|
|
// This is used by wxExecute(wxEXEC_NOEVENTS) implementation only.
|
2013-07-02 20:31:03 -04:00
|
|
|
//
|
|
|
|
// The pointer to the handler used for processing events on this descriptor
|
|
|
|
// is returned so that it can be deleted when we no longer needed it.
|
|
|
|
wxFDIOHandler* RegisterSignalWakeUpPipe(wxFDIODispatcher& dispatcher);
|
|
|
|
|
2007-05-14 19:43:39 -04:00
|
|
|
private:
|
|
|
|
// signal handler set up by SetSignalHandler() for all signals we handle,
|
|
|
|
// it just adds the signal to m_signalsCaught -- the real processing is
|
|
|
|
// done later, when CheckSignal() is called
|
|
|
|
static void HandleSignal(int signal);
|
|
|
|
|
|
|
|
|
|
|
|
// signals for which HandleSignal() had been called (reset from
|
|
|
|
// CheckSignal())
|
|
|
|
sigset_t m_signalsCaught;
|
|
|
|
|
|
|
|
// the signal handlers
|
|
|
|
WX_DECLARE_HASH_MAP(int, SignalHandler, wxIntegerHash, wxIntegerEqual, SignalHandlerHash);
|
|
|
|
SignalHandlerHash m_signalHandlerHash;
|
2013-07-02 20:31:03 -04:00
|
|
|
|
|
|
|
// pipe used for wake up signal handling: if a signal arrives while we're
|
|
|
|
// blocking for input, writing to this pipe triggers a call to our CheckSignal()
|
|
|
|
wxWakeUpPipe *m_signalWakeUpPipe;
|
2007-05-14 19:43:39 -04:00
|
|
|
};
|