common: Don't use unsafe functions when handling POSIX signals
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 5 Oct 2018 21:07:04 +0000 (23:07 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 14 Oct 2018 19:34:40 +0000 (21:34 +0200)
commitc015fbf8afaf64fbb5a8e2122e2a1ecf0325b1a1
treee6ceaac15de90d4a52f4d879c19db426a5f5f4db
parent893f0c21b72d7e4aedde092887073c590155b6d9
common: Don't use unsafe functions when handling POSIX signals

The set of functions we're allowed to safely use in a POSIX signal
handler is very limited, and certainly does not include anything Qt.
While our previous implementation seemingly worked anyway as long as
all it did was quitting the application, we now start seeing issues
when doing a proper shutdown.

Fix this by providing a generic API for watching signal-like external
events that can be specialized for the various platforms we support.
Provide PosixSignalWatcher, which uses socket notification to safely
hand over control from the signal handler to the Qt event loop.

Also provide an implementation for Windows that still uses the
previous approach; since Windows doesn't support socketpair(), we
can't easily reuse the POSIX implementation. On the bright side, so
far we don't know if signal handlers on Windows face the same
limitations as on POSIX anyway...
Also on Windows we now support console events, i.e. Ctrl+C as well
as closing the console window.
src/common/CMakeLists.txt
src/common/abstractsignalwatcher.h [new file with mode: 0644]
src/common/posixsignalwatcher.cpp [new file with mode: 0644]
src/common/posixsignalwatcher.h [new file with mode: 0644]
src/common/quassel.cpp
src/common/quassel.h
src/common/windowssignalwatcher.cpp [new file with mode: 0644]
src/common/windowssignalwatcher.h [new file with mode: 0644]
src/core/coreapplication.cpp
src/qtui/monoapplication.cpp
src/qtui/qtuiapplication.cpp