diff options
author | Christian S.J. Peron <csjp@FreeBSD.org> | 2004-08-10 01:49:46 +0000 |
---|---|---|
committer | Christian S.J. Peron <csjp@FreeBSD.org> | 2004-08-10 01:49:46 +0000 |
commit | f8da56fda8d4eb4543e51d02cf50aa8ce26d8e6a (patch) | |
tree | 0e18b0293bc5fc8ad411546e9e30c42651f89143 /usr.sbin/watch/watch.c | |
parent | c8c216d558faf32ceb79b43c78ec977392e96203 (diff) | |
download | src-f8da56fda8d4eb4543e51d02cf50aa8ce26d8e6a.tar.gz src-f8da56fda8d4eb4543e51d02cf50aa8ce26d8e6a.zip |
By default, the watch utility will attempt to open /dev/snp0, if
another process already has /dev/snp0 open, the snp(4) will return
EBUSY, in which case watch will try to open /dev/snp1..9. Currently
watch does not check errno to see if the failure was a result of EBUSY.
This results in watch making futile attempts to open snp0..snp9 even
though devices may not exist or the caller does not have permissions
to access the device.
In addition to this, it attempts to setup the screen for snooping even
though it may not ever get an snp device.
So this patch does two things
1) Checks errno for EBUSY, if open(2) fails for another reason
print that reason and exit.
2) setup the terminal for snooping after the snp descriptor has
been obtained.
Approved by: bmilekic (mentor)
Notes
Notes:
svn path=/head/; revision=133419
Diffstat (limited to 'usr.sbin/watch/watch.c')
-rw-r--r-- | usr.sbin/watch/watch.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c index 1e630dbc85a3..049fc84297d2 100644 --- a/usr.sbin/watch/watch.c +++ b/usr.sbin/watch/watch.c @@ -25,6 +25,7 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <err.h> +#include <errno.h> #include <locale.h> #include <paths.h> #include <signal.h> @@ -165,8 +166,11 @@ open_snp(void) if (opt_snpdev == NULL) for (c = '0'; c <= '9'; c++) { snp[pos] = c; - if ((f = open(snp, mode)) < 0) - continue; + if ((f = open(snp, mode)) < 0) { + if (errno == EBUSY) + continue; + err(1, "open %s", snp); + } return f; } else @@ -331,8 +335,8 @@ main(int ac, char *av[]) signal(SIGINT, cleanup); - setup_scr(); snp_io = open_snp(); + setup_scr(); if (*(av += optind) == NULL) { if (opt_interactive && !opt_no_switch) |