aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/watch
diff options
context:
space:
mode:
authorOlivier Houchard <cognet@FreeBSD.org>2005-09-18 19:24:05 +0000
committerOlivier Houchard <cognet@FreeBSD.org>2005-09-18 19:24:05 +0000
commitb615d79f9b74b369de148a8d894b01878e2da21c (patch)
treec0e3b0f7e9d5deef847b7a805f4b7ee322ca619f /usr.sbin/watch
parent30ce1aad9c81e2886a6132006530020c87c41484 (diff)
downloadsrc-b615d79f9b74b369de148a8d894b01878e2da21c.tar.gz
src-b615d79f9b74b369de148a8d894b01878e2da21c.zip
Open the tty device and pass the fd for SNPSTTY.
MFC after: 3 days
Notes
Notes: svn path=/head/; revision=150299
Diffstat (limited to 'usr.sbin/watch')
-rw-r--r--usr.sbin/watch/watch.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c
index 049fc84297d2..a062ae02d67a 100644
--- a/usr.sbin/watch/watch.c
+++ b/usr.sbin/watch/watch.c
@@ -75,7 +75,7 @@ const char *opt_snpdev;
char dev_name[DEV_NAME_LEN];
int snp_io;
-dev_t snp_tty;
+int snp_tty = 0;
int std_in = 0, std_out = 1;
@@ -187,6 +187,8 @@ cleanup(int signo __unused)
if (opt_timestamp)
timestamp("Logging Exited.");
close(snp_io);
+ if (snp_tty != 0)
+ close(snp_tty);
unset_tty();
exit(EX_OK);
}
@@ -253,7 +255,11 @@ set_dev(const char *name)
if ((sb.st_mode & S_IFMT) != S_IFCHR)
fatal(EX_DATAERR, "must be a character device");
- snp_tty = sb.st_rdev;
+ if (snp_tty != 0)
+ close(snp_tty);
+ snp_tty = open(buf, O_RDONLY);
+ if (snp_tty < 0)
+ fatal(EX_DATAERR, "can't open device");
attach_snp();
}