From d4c116040ff452a66a5764c3a21248b8269aa55f Mon Sep 17 00:00:00 2001 From: cgd Date: Wed, 30 Mar 1994 09:53:07 +0000 Subject: [PATCH] be a bit smarter when being verbose --- sbin/ttyflags/ttyflags.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sbin/ttyflags/ttyflags.c b/sbin/ttyflags/ttyflags.c index fc754c92a238..de207b3d77bd 100644 --- a/sbin/ttyflags/ttyflags.c +++ b/sbin/ttyflags/ttyflags.c @@ -35,7 +35,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char rcsid[] = "$Id: ttyflags.c,v 1.1 1994/03/30 09:29:19 cgd Exp $"; +static char rcsid[] = "$Id: ttyflags.c,v 1.2 1994/03/30 09:53:07 cgd Exp $"; #endif /* not lint */ #include @@ -185,13 +185,17 @@ change_ttyflags(tep) /* Open the device NON-BLOCKING, set the flags, and close it. */ if ((fd = open(path, O_RDONLY | O_NONBLOCK, 0)) == -1) { - warn("open %s", path); - return (1); - } - if (ioctl(fd, TIOCSFLAGS, &flags) == -1 && errno != ENOTTY) { - warn("TIOCSFLAGS on %s", path); - rval = 1; + if (errno != ENOENT || (st & TTY_ON) != 0) + rval = 1; + if (rval || vflag) + warn("open %s", path); + return (rval); } + if (ioctl(fd, TIOCSFLAGS, &flags) == -1) + if (errno != ENOTTY || vflag) { + warn("TIOCSFLAGS on %s", path); + rval = (errno != ENOTTY); + } if (close(fd) == -1) { warn("close %s", path); return (1);