]>
git.saurik.com Git - wxWidgets.git/blob - src/unix/appunix.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/unix/appunix.cpp
3 // Purpose: wxAppConsole with wxMainLoop implementation
4 // Author: Lukasz Michalski
7 // Copyright: (c) Lukasz Michalski
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/evtloop.h"
18 bool wxAppConsoleUnix::Initialize(int& argc
, wxChar
** argv
)
20 if ( !wxAppConsole::Initialize(argc
,argv
) )
23 if ( !m_mainLoop
->IsOk() )
26 sigemptyset(&m_signalsCaught
);
31 void wxAppConsoleUnix::HandleSignal(int signal
)
33 wxAppConsoleUnix
* const app
= wxTheApp
;
37 sigaddset(&(app
->m_signalsCaught
), signal
);
41 void wxAppConsoleUnix::CheckSignal()
43 for ( SignalHandlerHash::iterator it
= m_signalHandlerHash
.begin();
44 it
!= m_signalHandlerHash
.end();
48 if ( sigismember(&m_signalsCaught
, sig
) )
50 sigdelset(&m_signalsCaught
, sig
);
56 bool wxAppConsoleUnix::SetSignalHandler(int signal
, SignalHandler handler
)
58 const bool install
= handler
!= SIG_DFL
&& handler
!= SIG_IGN
;
61 memset(&sa
, 0, sizeof(sa
));
62 sa
.sa_handler
= &wxAppConsoleUnix::HandleSignal
;
63 sa
.sa_flags
= SA_RESTART
;
64 int res
= sigaction(signal
, &sa
, 0);
67 wxLogSysError(_("Failed to install signal handler"));
72 m_signalHandlerHash
[signal
] = handler
;
74 m_signalHandlerHash
.erase(signal
);