Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Sep 2013 19:02:04 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r255261 - head/usr.sbin/watch
Message-ID:  <201309051902.r85J24bJ035211@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Thu Sep  5 19:02:03 2013
New Revision: 255261
URL: http://svnweb.freebsd.org/changeset/base/255261

Log:
  watch: Do not mess up the tty modes on early error.
  
  Record the initial state earlier, so it is always safe to restore it.
  
  One way this happens is if watch(8) is started by a user that does not have
  access to /dev/snp. The result is "staircase effect" during later commands.
  
  PR:		bin/153052
  MFC after:	1 week

Modified:
  head/usr.sbin/watch/watch.c

Modified: head/usr.sbin/watch/watch.c
==============================================================================
--- head/usr.sbin/watch/watch.c	Thu Sep  5 18:45:23 2013	(r255260)
+++ head/usr.sbin/watch/watch.c	Thu Sep  5 19:02:03 2013	(r255261)
@@ -110,7 +110,6 @@ set_tty(void)
 {
 	struct termios	ntty;
 
-	tcgetattr(std_in, &otty);
 	ntty = otty;
 	ntty.c_lflag &= ~ICANON;	/* disable canonical operation */
 	ntty.c_lflag &= ~ECHO;
@@ -324,6 +323,8 @@ main(int ac, char *av[])
 			usage();
 		}
 
+	tcgetattr(std_in, &otty);
+
 	if (modfind("snp") == -1)
 		if (kldload("snp") == -1 || modfind("snp") == -1)
 			warn("snp module not available");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309051902.r85J24bJ035211>