]>
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 wxAppConsole::Initialize(int& argc
, wxChar
** argv
)
20 if ( !wxAppConsoleBase::Initialize(argc
,argv
) )
23 sigemptyset(&m_signalsCaught
);
28 void wxAppConsole::HandleSignal(int signal
)
30 wxAppConsole
* const app
= wxTheApp
;
34 sigaddset(&(app
->m_signalsCaught
), signal
);
38 void wxAppConsole::CheckSignal()
40 for ( SignalHandlerHash::iterator it
= m_signalHandlerHash
.begin();
41 it
!= m_signalHandlerHash
.end();
45 if ( sigismember(&m_signalsCaught
, sig
) )
47 sigdelset(&m_signalsCaught
, sig
);
53 bool wxAppConsole::SetSignalHandler(int signal
, SignalHandler handler
)
55 const bool install
= handler
!= SIG_DFL
&& handler
!= SIG_IGN
;
58 memset(&sa
, 0, sizeof(sa
));
59 sa
.sa_handler
= &wxAppConsole::HandleSignal
;
60 sa
.sa_flags
= SA_RESTART
;
61 int res
= sigaction(signal
, &sa
, 0);
64 wxLogSysError(_("Failed to install signal handler"));
69 m_signalHandlerHash
[signal
] = handler
;
71 m_signalHandlerHash
.erase(signal
);