aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/watch
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2013-09-05 19:02:03 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2013-09-05 19:02:03 +0000
commit79e6a2c01e19829cb707fcbed75189aa0ffc2836 (patch)
tree49a07c34d2cfbcc961afa019aae31aa260fa2b23 /usr.sbin/watch
parentb6f49c23a36f329cbf1e7f28078e17fd87f0e245 (diff)
downloadsrc-79e6a2c01e19829cb707fcbed75189aa0ffc2836.tar.gz
src-79e6a2c01e19829cb707fcbed75189aa0ffc2836.zip
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
Notes
Notes: svn path=/head/; revision=255261
Diffstat (limited to 'usr.sbin/watch')
-rw-r--r--usr.sbin/watch/watch.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c
index e69534de55c4..eecf0d32db2a 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");