diff --git a/src/Pty.cpp b/src/Pty.cpp index 02dab684..106f76a3 100644 --- a/src/Pty.cpp +++ b/src/Pty.cpp @@ -278,22 +278,6 @@ void Pty::closePty() pty()->close(); } -void Pty::sendEof() -{ - if (pty()->masterFd() < 0) { - qCDebug(KonsoleDebug) << "Unable to get eof char attribute, terminal not connected."; - return; - } - struct ::termios ttyAttributes; - pty()->tcGetAttr(&ttyAttributes); - char eofChar = ttyAttributes.c_cc[VEOF]; - if (pty()->write(QByteArray(1, eofChar)) == -1) { - qCDebug(KonsoleDebug) << "Unable to send EOF"; - } - - pty()->waitForBytesWritten(); -} - int Pty::foregroundProcessGroup() const { const int master_fd = pty()->masterFd(); diff --git a/src/Pty.h b/src/Pty.h index 80020eff..be406c62 100644 --- a/src/Pty.h +++ b/src/Pty.h @@ -122,11 +122,6 @@ public: */ void closePty(); - /** - * Sends EOF to the controlled process, this is the preferred method of telling e. g. bash to close - */ - void sendEof(); - public Q_SLOTS: /** * Put the pty into UTF-8 mode on systems which support it. diff --git a/src/session/Session.cpp b/src/session/Session.cpp index 0523011a..ba6dcf46 100644 --- a/src/session/Session.cpp +++ b/src/session/Session.cpp @@ -872,27 +872,16 @@ bool Session::closeInNormalWay() return true; } - static QSet knownShells({QStringLiteral("ash"), QStringLiteral("bash"), QStringLiteral("csh"), QStringLiteral("dash"), QStringLiteral("fish"), QStringLiteral("hush"), QStringLiteral("ksh"), QStringLiteral("mksh"), QStringLiteral("pdksh"), QStringLiteral("tcsh"), QStringLiteral("zsh")}); - - // If only the session's shell is running, try sending an EOF for a clean exit - if (!isForegroundProcessActive() && knownShells.contains(QFileInfo(_program).fileName())) { - _shellProcess->sendEof(); - - if (_shellProcess->waitForFinished(1000)) { - return true; - } - qWarning() << "shell did not close, sending SIGHUP"; - } - - - // We tried asking nicely, ask a bit less nicely + // try SIGHUP, afterwards do hard kill + // this is the sequence used by most other terminal emulators like xterm, gnome-terminal, ... + // see bug 401898 for details about tries to have some "soft-terminate" via EOF character if (kill(SIGHUP)) { return true; - } else { - qWarning() << "Process " << processId() << " did not die with SIGHUP"; - _shellProcess->closePty(); - return (_shellProcess->waitForFinished(1000)); } + + qWarning() << "Process " << processId() << " did not die with SIGHUP"; + _shellProcess->closePty(); + return (_shellProcess->waitForFinished(1000)); } bool Session::closeInForceWay()