summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-11-04 16:21:27 +0100
committerSimon Rettberg2019-11-04 16:21:27 +0100
commiteeb142dc8b71a66eb9324852549a85604ab737d7 (patch)
tree4e662cdecc4897b0162592d15ffef6431654650b
parentTry even harder to restore focus after spawning openbox (diff)
downloadvmchooser2-eeb142dc8b71a66eb9324852549a85604ab737d7.tar.gz
vmchooser2-eeb142dc8b71a66eb9324852549a85604ab737d7.tar.xz
vmchooser2-eeb142dc8b71a66eb9324852549a85604ab737d7.zip
Start session_start script detachedv26
Qt kills all QProcess instances in execv(), which will stop our SESSIONSTART script mid-execution.
-rw-r--r--src/dialog.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index bdeab16..94b271c 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -170,31 +170,27 @@ void Dialog::on_treeView_doubleClicked(const QModelIndex& index)
UserConfig::setNewsHelpOpen(!ui->helpBox->isHidden());
UserConfig::sync();
- QProcess *process = nullptr;
+ qint64 scriptPid = 0;
if (QFile::exists(SESSION_START_SCRIPT)) {
// Companion script
- process = new QProcess;
- QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
- env.insert("SESSION_NAME", s->shortDescription());
- env.insert("SESSION_UUID", s->uuid());
- env.insert("SESSION_CMD", s->execCommand());
+ setenv("SESSION_NAME", s->shortDescription().toLocal8Bit().constData(), 1);
+ setenv("SESSION_UUID", s->uuid().toLocal8Bit().constData(), 1);
+ setenv("SESSION_CMD", s->execCommand().toLocal8Bit().constData(), 1);
if (s->type() == Session::VSESSION) {
- env.insert("SESSION_TYPE", "VSESSION");
+ setenv("SESSION_TYPE", "VSESSION", 1);
} else if (s->type() == Session::XSESSION) {
- env.insert("SESSION_TYPE", "XSESSION");
+ setenv("SESSION_TYPE", "XSESSION", 1);
+ }
+ if (!QProcess::startDetached(SESSION_START_SCRIPT, QStringList(), QStringLiteral("/"), &scriptPid)) {
+ scriptPid = 0;
}
- process->setProcessEnvironment(env);
- process->start(SESSION_START_SCRIPT);
- process->closeReadChannel(QProcess::StandardError);
- process->closeReadChannel(QProcess::StandardOutput);
- process->closeWriteChannel();
}
// Run session
s->run();
// Should not return on success
- if (process != nullptr) {
- process->terminate();
+ if (scriptPid > 0) {
+ ::kill(pid_t(scriptPid), SIGTERM);
}
QMessageBox::critical(
this, trUtf8("vmchooser"),