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:
    http://permalink.gmane.org/gmane.comp.shells.bash.bugs/12602

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
This commit is contained in:
Martin T. H. Sandsmark
2016-07-10 00:47:34 +02:00
parent e109863ba4
commit 2f1c8cf397
3 changed files with 30 additions and 0 deletions

View File

@@ -281,6 +281,22 @@ void Pty::closePty()
pty()->close();
}
void Pty::sendEof()
{
if (pty()->masterFd() < 0) {
qWarning() << "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))) {
qWarning() << "Unable to send EOF";
}
pty()->waitForBytesWritten();
}
int Pty::foregroundProcessGroup() const
{
int foregroundPid = tcgetpgrp(pty()->masterFd());