From aa76541e0c7c9ecb87e7ddb1c153c2ee80544611 Mon Sep 17 00:00:00 2001 From: Martijn van Duren Date: Sat, 28 May 2016 18:30:36 +0000 Subject: Test if stdin is a terminal before resetting the tty state. Diff supplied by Kai Antweiler. OK semarie@ and deraadt@ --- usr.bin/vi/cl/cl_screen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'usr.bin/vi/cl') diff --git a/usr.bin/vi/cl/cl_screen.c b/usr.bin/vi/cl/cl_screen.c index 744b03d7224..6f75e4bc61d 100644 --- a/usr.bin/vi/cl/cl_screen.c +++ b/usr.bin/vi/cl/cl_screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cl_screen.c,v 1.26 2016/02/11 16:34:12 tim Exp $ */ +/* $OpenBSD: cl_screen.c,v 1.27 2016/05/28 18:30:35 martijn Exp $ */ /*- * Copyright (c) 1993, 1994 @@ -165,7 +165,8 @@ cl_quit(GS *gp) * implementations get it wrong. It may discard type-ahead characters * from the tty queue. */ - (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig); + if (F_ISSET(clp, CL_STDIN_TTY)) + (void)tcsetattr(STDIN_FILENO, TCSADRAIN | TCSASOFT, &clp->orig); F_CLR(clp, CL_SCR_EX_INIT | CL_SCR_VI_INIT); return (rval); -- cgit v1.2.3