Mercurial > octave
changeset 29132:118b38c17805
also restore stdin and stdout in QUnixTerminalImpl destructor
* QUnixTerminalImpl.h, QUnixTerminalImpl.cpp
(QUnixTerminalImpl::fdstdin, QUnixTerminalImpl::fdstdout):
New data members.
(QUnixTerminalImpl::connectToPty): Save stdin and stdout file
numbers.
(QUnixTerminalImpl::~QUnixTerminalImpl): Restore stdin and stdout.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 02 Dec 2020 14:22:15 -0500 |
parents | 77ba9dfe5b29 |
children | 0d8e5f890a9b |
files | libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp Wed Dec 02 15:00:45 2020 -0500 +++ b/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp Wed Dec 02 14:22:15 2020 -0500 @@ -107,8 +107,12 @@ void QUnixTerminalImpl::connectToPty() { - // Store the file descriptor associated with the STDERR stream onto - // another temporary file descriptor for reconnect in the destructor. + // Store the file descriptor associated with the STDIN, STDOUT, and + // STDERR streams onto another temporary file descriptor for + // reconnect in the destructor. + + fdstdin = dup (STDIN_FILENO); + fdstdout = dup (STDOUT_FILENO); fdstderr = dup (STDERR_FILENO); int fds = m_kpty->slaveFd(); @@ -136,7 +140,11 @@ delete m_kpty; delete m_terminalView; - // Restore stderr so that any errors at exit might appear somewhere. + // Restore STDIN, STDOUT, and STDERR so that I/O at exit will work + // as expected. + + dup2 (fdstdin, STDIN_FILENO); + dup2 (fdstdout, STDOUT_FILENO); dup2 (fdstderr, STDERR_FILENO); emit destroyed();