Commit 2f1c8cf3 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

Send EOF when closing first, before SIGHUP

According to the bash maintainer sending EOF is the appropriate way of
telling e. g. bash to quit:

I wasn't able to get KPtyProcess to send that in a nice way (calling
setStandardInputFile(QProcess::nullDevice(), for example), so we fetch
the EOF character manually with tcgetattr and send that.

BUG: 185140
REVIEW: 128416
parent e109863b
......@@ -281,6 +281,22 @@ void Pty::closePty()
void Pty::sendEof()
if (pty()->masterFd() < 0) {
qWarning() << "Unable to get eof char attribute, terminal not connected.";
struct ::termios ttyAttributes;
char eofChar = ttyAttributes.c_cc[VEOF];
if (!pty()->write(QByteArray(1, eofChar))) {
qWarning() << "Unable to send EOF";
int Pty::foregroundProcessGroup() const
int foregroundPid = tcgetpgrp(pty()->masterFd());
......@@ -141,6 +141,11 @@ public:
void closePty();
* Sends EOF to the controlled process, this is the preferred method of telling e. g. bash to close
void sendEof();
public slots:
* Put the pty into UTF-8 mode on systems which support it.
......@@ -822,6 +822,15 @@ bool Session::closeInNormalWay()
return true;
if (_shellProcess->waitForFinished(1000)) {
return true;
qWarning() << "shell did not close, sending SIGHUP";
// We tried asking nicely, ask a bit less nicely
if (kill(SIGHUP)) {
return true;
} else {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment