From cbeddbcc36a506db16de76f805b78fab65f5311a Mon Sep 17 00:00:00 2001 From: cognet Date: Sun, 18 Sep 2005 19:24:05 +0000 Subject: Open the tty device and pass the fd for SNPSTTY. MFC after: 3 days --- usr.sbin/watch/watch.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c index 049fc84..a062ae0 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(); } -- cgit v1.1