Unblock signals in child processes

We need to unblock the signals blocked with pthread_sigmask.
This caused kdeinit to block, because it relies on SIGUSR1.

BUG: 356580
FIXED-IN: 5.5.1
REVIEW: 126361
This commit is contained in:
Martin Gräßlin 2015-12-15 10:22:03 +01:00
parent 2f1731222a
commit 14b9046ad2
5 changed files with 39 additions and 6 deletions

View file

@ -197,7 +197,7 @@ void ApplicationWayland::continueStartupWithX()
environment.insert(QStringLiteral("QT_QPA_PLATFORM"), QStringLiteral("wayland")); environment.insert(QStringLiteral("QT_QPA_PLATFORM"), QStringLiteral("wayland"));
environment.remove("DISPLAY"); environment.remove("DISPLAY");
environment.remove("WAYLAND_DISPLAY"); environment.remove("WAYLAND_DISPLAY");
QProcess *p = new QProcess(this); QProcess *p = new Process(this);
p->setProcessChannelMode(QProcess::ForwardedErrorChannel); p->setProcessChannelMode(QProcess::ForwardedErrorChannel);
auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished); auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished);
connect(p, finishedSignal, this, connect(p, finishedSignal, this,
@ -217,7 +217,7 @@ void ApplicationWayland::continueStartupWithX()
m_environment.insert(QStringLiteral("DISPLAY"), QString::fromUtf8(qgetenv("DISPLAY"))); m_environment.insert(QStringLiteral("DISPLAY"), QString::fromUtf8(qgetenv("DISPLAY")));
// start session // start session
if (!m_sessionArgument.isEmpty()) { if (!m_sessionArgument.isEmpty()) {
QProcess *p = new QProcess(this); QProcess *p = new Process(this);
p->setProcessChannelMode(QProcess::ForwardedErrorChannel); p->setProcessChannelMode(QProcess::ForwardedErrorChannel);
p->setProcessEnvironment(m_environment); p->setProcessEnvironment(m_environment);
auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished); auto finishedSignal = static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished);
@ -229,7 +229,7 @@ void ApplicationWayland::continueStartupWithX()
for (const QString &application: m_applicationsToStart) { for (const QString &application: m_applicationsToStart) {
// note: this will kill the started process when we exit // note: this will kill the started process when we exit
// this is going to happen anyway as we are the wayland and X server the app connects to // this is going to happen anyway as we are the wayland and X server the app connects to
QProcess *p = new QProcess(this); QProcess *p = new Process(this);
p->setProcessChannelMode(QProcess::ForwardedErrorChannel); p->setProcessChannelMode(QProcess::ForwardedErrorChannel);
p->setProcessEnvironment(m_environment); p->setProcessEnvironment(m_environment);
p->start(application); p->start(application);
@ -299,7 +299,7 @@ void ApplicationWayland::startXwaylandServer()
m_xcbConnectionFd = sx[0]; m_xcbConnectionFd = sx[0];
m_xwaylandProcess = new QProcess(kwinApp()); m_xwaylandProcess = new Process(kwinApp());
m_xwaylandProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel); m_xwaylandProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel);
m_xwaylandProcess->setProgram(QStringLiteral("Xwayland")); m_xwaylandProcess->setProgram(QStringLiteral("Xwayland"));
QProcessEnvironment env = m_environment; QProcessEnvironment env = m_environment;

View file

@ -1007,7 +1007,7 @@ void RuleBook::edit(AbstractClient* c, bool whole_app)
args << QStringLiteral("--wid") << QString::number(c->window()); args << QStringLiteral("--wid") << QString::number(c->window());
if (whole_app) if (whole_app)
args << QStringLiteral("--whole-app"); args << QStringLiteral("--whole-app");
QProcess *p = new QProcess(this); QProcess *p = new Process(this);
p->setArguments(args); p->setArguments(args);
p->setProcessEnvironment(kwinApp()->processStartupEnvironment()); p->setProcessEnvironment(kwinApp()->processStartupEnvironment());
p->setProgram(QStringLiteral(KWIN_RULES_DIALOG_BIN)); p->setProgram(QStringLiteral(KWIN_RULES_DIALOG_BIN));

View file

@ -330,7 +330,7 @@ void UserActionsMenu::init()
// opens the KWin configuration // opens the KWin configuration
QStringList args; QStringList args;
args << QStringLiteral("--icon") << QStringLiteral("preferences-system-windows") << configModules(false); args << QStringLiteral("--icon") << QStringLiteral("preferences-system-windows") << configModules(false);
QProcess *p = new QProcess(this); QProcess *p = new Process(this);
p->setArguments(args); p->setArguments(args);
p->setProcessEnvironment(kwinApp()->processStartupEnvironment()); p->setProcessEnvironment(kwinApp()->processStartupEnvironment());
p->setProgram(QStringLiteral("kcmshell5")); p->setProgram(QStringLiteral("kcmshell5"));

View file

@ -42,6 +42,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "atoms.h" #include "atoms.h"
#include "workspace.h" #include "workspace.h"
#include <signal.h>
#endif #endif
Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtCriticalMsg) Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtCriticalMsg)
@ -142,6 +144,22 @@ void ungrabXKeyboard()
xcb_ungrab_keyboard(connection(), XCB_TIME_CURRENT_TIME); xcb_ungrab_keyboard(connection(), XCB_TIME_CURRENT_TIME);
} }
Process::Process(QObject *parent)
: QProcess(parent)
{
}
Process::~Process() = default;
void Process::setupChildProcess()
{
sigset_t userSiganls;
sigemptyset(&userSiganls);
sigaddset(&userSiganls, SIGUSR1);
sigaddset(&userSiganls, SIGUSR2);
pthread_sigmask(SIG_UNBLOCK, &userSiganls, nullptr);
}
#endif #endif
// converting between X11 mouse/keyboard state mask and Qt button/keyboard states // converting between X11 mouse/keyboard state mask and Qt button/keyboard states

15
utils.h
View file

@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QPoint> #include <QPoint>
#include <QRect> #include <QRect>
#include <QScopedPointer> #include <QScopedPointer>
#include <QProcess>
// system // system
#include <limits.h> #include <limits.h>
Q_DECLARE_LOGGING_CATEGORY(KWIN_CORE) Q_DECLARE_LOGGING_CATEGORY(KWIN_CORE)
@ -227,6 +228,20 @@ private:
bool m_valid = false; bool m_valid = false;
}; };
/**
* QProcess subclass which unblocks SIGUSR in the child process.
**/
class KWIN_EXPORT Process : public QProcess
{
Q_OBJECT
public:
explicit Process(QObject *parent = nullptr);
virtual ~Process();
protected:
void setupChildProcess() override;
};
} // namespace } // namespace
// Must be outside namespace // Must be outside namespace