From 216c4b811a5a19157ce9843527ec2f96517c6699 Mon Sep 17 00:00:00 2001 From: David Adam Date: Mon, 16 Oct 2017 12:13:30 +0800 Subject: [PATCH] only call ioctl to export new termsize if process is in the foreground Closes #4477. --- src/common.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common.cpp b/src/common.cpp index d212e200b..9d78b5f59 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1592,7 +1592,10 @@ static void export_new_termsize(struct winsize *new_termsize) { env_set_one(L"LINES", ENV_GLOBAL | (lines.missing_or_empty() ? ENV_DEFAULT : ENV_EXPORT), buf); #ifdef HAVE_WINSIZE - ioctl(STDOUT_FILENO, TIOCSWINSZ, new_termsize); + // Only write the new terminal size if we are in the foreground (#4477) + if (tcgetpgrp(STDOUT_FILENO) == getpgrp()) { + ioctl(STDOUT_FILENO, TIOCSWINSZ, new_termsize); + } #endif }