From 4b58ef1a3ff9c3b82934962811f08ae233842ce0 Mon Sep 17 00:00:00 2001 From: jilles Date: Thu, 5 Sep 2013 19:02:03 +0000 Subject: 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 --- usr.sbin/watch/watch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c index e69534d..eecf0d3 100644 --- a/usr.sbin/watch/watch.c +++ b/usr.sbin/watch/watch.c @@ -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"); -- cgit v1.1