Skip to content

Commit

Permalink
fix: prevent treeland exit by ctrl+c
Browse files Browse the repository at this point in the history
Signed-off-by: ComixHe <[email protected]>
  • Loading branch information
ComixHe committed Jan 16, 2024
1 parent b5c6b0b commit 690b8c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/helper/HelperApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ namespace SDDM {
, m_session(new UserSession(this))
, m_socket(new QLocalSocket(this)) {
qInstallMessageHandler(HelperMessageHandler);
//TODO: replace this workaround in the future
SignalHandler *s = new SignalHandler(this);

Check warning on line 58 in src/helper/HelperApp.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Variable 's' is assigned a value that is never used.
QObject::connect(s, &SignalHandler::sigtermReceived, m_session, [] {
QCoreApplication::instance()->exit(-1);
});

QTimer::singleShot(0, this, SLOT(setUp()));
}
Expand Down Expand Up @@ -130,7 +128,7 @@ namespace SDDM {
exit(Auth::HELPER_OTHER_ERROR);
return;
}

connect(m_socket, &QLocalSocket::connected, this, &HelperApp::doAuth);
if(!m_backend->identifyOnly()){
connect(m_session, &UserSession::finished, this, &HelperApp::sessionFinished);
Expand Down Expand Up @@ -315,7 +313,6 @@ namespace SDDM {
Q_ASSERT(getuid() == 0);

m_session->stop();

if(!m_backend->identifyOnly()){
m_backend->closeSession();
}
Expand Down
2 changes: 1 addition & 1 deletion src/helper/UserSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ namespace SDDM {

// take control of the tty
if (takeControl) {
if (ioctl(STDIN_FILENO, TIOCSCTTY) < 0) {
if (ioctl(STDIN_FILENO, TIOCSCTTY, 0) < 0) {
const auto error = strerror(errno);
qCritical().nospace() << "Failed to take control of " << ttyString << " (" << QFileInfo(ttyString).owner() << "): " << error;
_exit(Auth::HELPER_TTY_ERROR);
Expand Down
3 changes: 3 additions & 0 deletions src/treeland/treeland-fake-session/fake-session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "shortcutmanager.h"
#include "Constants.h"
#include "SignalHandler.h"

#include <QDebug>
#include <QObject>
Expand Down Expand Up @@ -210,6 +211,8 @@ FakeSession::FakeSession(int argc, char* argv[])
, m_toplevelManager(new Protocols::ForeignToplevelManager)
, m_extForeignToplevelList(new Protocols::ExtForeignToplevelList)
{
auto *s = new SDDM::SignalHandler(this);

connect(m_shortcutManager, &Protocols::ShortcutManager::activeChanged, this, [this] {
qDebug() << m_shortcutManager->isActive();

Expand Down

0 comments on commit 690b8c1

Please sign in to comment.