Sanitize signal handling in ksmserver

Authored by jpalecek on Apr 13 2018, 9:40 PM.

Description

Sanitize signal handling in ksmserver

Summary:
The TERM signal handling in ksmserver invokes functions which are not async-signal safe, like Qt functions and C++ destructors. Moreover, the signal handling can occur in other than the main thread, which leads to Qt complaining about functions being invoked from the wrong thread. Such a crash can be seen in a report of https://bugs.kde.org/show_bug.cgi?id=384316.

To fix both of these issues, this change makes the signal handling use the self-pipe trick, which signals the need for termination to the main thread by writing to a special-purpose file descriptor. The main loop then takes care of the termination. This is mostly inspired by http://doc.qt.io/qt-5/unix-signals.html.

Note that QApplication::quit already does what we need when destroying the server, particularly deleting the_server/calling cleanUp().

Reviewers: Plasma, davidedmundson

Reviewed By: Plasma, davidedmundson

Subscribers: broulik, graesslin, davidedmundson, plasma-devel

Tags: Plasma

Differential Revision: https://phabricator.kde.org/D8673

Details

Committed
davidedmundsonApr 13 2018, 9:53 PM
Reviewer
Plasma
Differential Revision
D8673: Sanitize signal handling in ksmserver
Parents
R120:28ddeb274bd9: Fix logic error in DBus script evaluation
Branches
Unknown
Tags
Unknown