]>
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"
15 //this code should not be compiled when GUI is defined
16 //(monolithic build issue)
22 bool wxAppConsoleUnix::Initialize(int& argc
, wxChar
** argv
)
24 if ( !wxAppConsole::Initialize(argc
,argv
) )
27 if ( !m_mainLoop
->IsOk() )
30 sigemptyset(&m_signalsCaught
);
35 void wxAppConsoleUnix::HandleSignal(int signal
)
37 wxAppConsoleUnix
* const app
= wxTheApp
;
41 sigaddset(&(app
->m_signalsCaught
), signal
);
45 void wxAppConsoleUnix::CheckSignal()
47 for ( SignalHandlerHash::iterator it
= m_signalHandlerHash
.begin();
48 it
!= m_signalHandlerHash
.end();
52 if ( sigismember(&m_signalsCaught
, sig
) )
54 sigdelset(&m_signalsCaught
, sig
);
60 bool wxAppConsoleUnix::SetSignalHandler(int signal
, SignalHandler handler
)
62 const bool install
= handler
!= SIG_DFL
&& handler
!= SIG_IGN
;
65 memset(&sa
, 0, sizeof(sa
));
66 sa
.sa_handler
= &wxAppConsoleUnix::HandleSignal
;
67 sa
.sa_flags
= SA_RESTART
;
68 int res
= sigaction(signal
, &sa
, 0);
71 wxLogSysError(_("Failed to install signal handler"));
76 m_signalHandlerHash
[signal
] = handler
;
78 m_signalHandlerHash
.erase(signal
);