mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
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)
This commit is contained in:
parent
c8c216d558
commit
f8da56fda8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=133419
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue