mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: unblock signals when setting handlers for them
generally, those signals should not be blocked but it seems something is blocking consequent SIGSEGV signals send by `kill` for example Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
053898e849
commit
d258df3881
3 changed files with 46 additions and 19 deletions
|
@ -87,6 +87,22 @@ static Atom kde_xdnd_drop = None;
|
||||||
static QByteArray* startup_id_tmp = nullptr;
|
static QByteArray* startup_id_tmp = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const int s_quit_signals[] = {
|
||||||
|
SIGTERM,
|
||||||
|
SIGHUP,
|
||||||
|
SIGINT,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
static void quit_handler(int sig)
|
||||||
|
{
|
||||||
|
KDE_signal(sig, SIG_DFL);
|
||||||
|
|
||||||
|
if (qApp) {
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Private data to make keeping binary compatibility easier
|
Private data to make keeping binary compatibility easier
|
||||||
*/
|
*/
|
||||||
|
@ -779,24 +795,17 @@ void KApplication::updateRemoteUserTimestamp( const QString& service, int time )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void quit_handler(int sig)
|
|
||||||
{
|
|
||||||
Q_UNUSED(sig);
|
|
||||||
|
|
||||||
KDE_signal(SIGTERM, SIG_DFL);
|
|
||||||
KDE_signal(SIGHUP, SIG_DFL);
|
|
||||||
KDE_signal(SIGINT, SIG_DFL);
|
|
||||||
|
|
||||||
if (qApp) {
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KApplication::quitOnSignal()
|
void KApplication::quitOnSignal()
|
||||||
{
|
{
|
||||||
KDE_signal(SIGTERM, quit_handler);
|
sigset_t handlermask;
|
||||||
KDE_signal(SIGHUP, quit_handler);
|
::sigemptyset(&handlermask);
|
||||||
KDE_signal(SIGINT, quit_handler);
|
int counter = 0;
|
||||||
|
while (s_quit_signals[counter]) {
|
||||||
|
KDE_signal(s_quit_signals[counter], quit_handler);
|
||||||
|
::sigaddset(&handlermask, s_quit_signals[counter]);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
::sigprocmask(SIG_UNBLOCK, &handlermask, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KApplication::setTopWidget( QWidget *topWidget )
|
void KApplication::setTopWidget( QWidget *topWidget )
|
||||||
|
|
|
@ -81,11 +81,15 @@ void KCrash::setCrashHandler(HandlerType handler)
|
||||||
|
|
||||||
s_crashHandler = handler;
|
s_crashHandler = handler;
|
||||||
|
|
||||||
|
sigset_t handlermask;
|
||||||
|
::sigemptyset(&handlermask);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
while (s_signals[counter]) {
|
while (s_signals[counter]) {
|
||||||
KDE_signal(s_signals[counter], s_crashHandler);
|
KDE_signal(s_signals[counter], s_crashHandler);
|
||||||
|
::sigaddset(&handlermask, s_signals[counter]);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
::sigprocmask(SIG_UNBLOCK, &handlermask, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
KCrash::HandlerType KCrash::crashHandler()
|
KCrash::HandlerType KCrash::crashHandler()
|
||||||
|
|
|
@ -73,6 +73,13 @@ typedef QMap<QString,QByteArray> AuthKeysMap;
|
||||||
|
|
||||||
namespace KIO {
|
namespace KIO {
|
||||||
|
|
||||||
|
static const int s_quit_signals[] = {
|
||||||
|
SIGTERM,
|
||||||
|
SIGHUP,
|
||||||
|
SIGINT,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
static QByteArray authInfoKey(const AuthInfo &authinfo)
|
static QByteArray authInfoKey(const AuthInfo &authinfo)
|
||||||
{
|
{
|
||||||
return KPasswdStore::makeKey(authinfo.url.prettyUrl());
|
return KPasswdStore::makeKey(authinfo.url.prettyUrl());
|
||||||
|
@ -178,6 +185,7 @@ extern "C" {
|
||||||
static void genericsig_handler(int sigNumber)
|
static void genericsig_handler(int sigNumber)
|
||||||
{
|
{
|
||||||
KDE_signal(sigNumber, SIG_IGN);
|
KDE_signal(sigNumber, SIG_IGN);
|
||||||
|
|
||||||
//WABA: Don't do anything that requires malloc, we can deadlock on it since
|
//WABA: Don't do anything that requires malloc, we can deadlock on it since
|
||||||
//a SIGTERM signal can come in while we are in malloc/free.
|
//a SIGTERM signal can come in while we are in malloc/free.
|
||||||
//kDebug()<<"kioslave : exiting due to signal "<<sigNumber;
|
//kDebug()<<"kioslave : exiting due to signal "<<sigNumber;
|
||||||
|
@ -209,9 +217,15 @@ SlaveBase::SlaveBase( const QByteArray &protocol,
|
||||||
act.sa_flags = 0;
|
act.sa_flags = 0;
|
||||||
sigaction(SIGPIPE, &act, 0);
|
sigaction(SIGPIPE, &act, 0);
|
||||||
|
|
||||||
KDE_signal(SIGINT, &genericsig_handler);
|
sigset_t handlermask;
|
||||||
KDE_signal(SIGQUIT, &genericsig_handler);
|
::sigemptyset(&handlermask);
|
||||||
KDE_signal(SIGTERM, &genericsig_handler);
|
int counter = 0;
|
||||||
|
while (s_quit_signals[counter]) {
|
||||||
|
KDE_signal(s_quit_signals[counter], genericsig_handler);
|
||||||
|
::sigaddset(&handlermask, s_quit_signals[counter]);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
::sigprocmask(SIG_UNBLOCK, &handlermask, NULL);
|
||||||
|
|
||||||
globalSlave = this;
|
globalSlave = this;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue