<table><tr><td style="">jpalecek created this revision.<br />Restricted Application added a project: Plasma.<br />Restricted Application added a subscriber: plasma-devel.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D8673" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>The TERM signal handling in ksmserver invokes functions which<br />
are not async-signal safe, like Qt functions and C++<br />
destructors. Moreover, the signal handling can occur in other than the<br />
main thread, which leads to Qt complaining about functions being<br />
invoked from the wrong thread. Such a crash can be seen in a report of<br />
"https://bugs.kde.org/show_bug.cgi?id=384316" <https://phabricator.kde.org/w/bug_384316/>.</p>
<p>To fix both of these issues, this change makes the signal handling use<br />
the self-pipe trick, which signals the need for termination to the<br />
main thread by writing to a special-purpose file descriptor. The main<br />
loop then takes care of the termination. This is mostly inspired by <a href="http://doc.qt.io/qt-5/unix-signals.html" class="remarkup-link" target="_blank" rel="noreferrer">http://doc.qt.io/qt-5/unix-signals.html</a>.</p>
<p>Note that <tt style="background: #ebebeb; font-size: 13px;">QApplication::quit</tt> already does what we need when destroying<br />
the server, particularly deleting <tt style="background: #ebebeb; font-size: 13px;">the_server</tt>/calling <tt style="background: #ebebeb; font-size: 13px;">cleanUp()</tt>.</p>
<p>BTW I noticed the code (here and in XIO error handler) makes quite<br />
sure the_server is zeroed. However, other code in ksmserver is not so<br />
keen on checking <tt style="background: #ebebeb; font-size: 13px;">the_server</tt> is !0 when using it.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R120 Plasma Workspace</div></div></div><br /><div><strong>BRANCH</strong><div><div>Plasma/5.10</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D8673" rel="noreferrer">https://phabricator.kde.org/D8673</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>ksmserver/server.cpp</div></div></div><br /><div><strong>To: </strong>jpalecek<br /><strong>Cc: </strong>plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart<br /></div>