Record the initial state earlier, so it is always safe to restore it.
One way this happens is if watch(8) is started by a user that does not have
access to /dev/snp. The result is "staircase effect" during later commands.
PR: bin/153052
MFC after: 1 week
- Remove unneeded whitespace for function calls.
- Add empty line at the top of functions without local variables.
- Change while (1) to for (;;).
MFC after: 1 week
Now we have a single /dev/snp device node, which can be opened by
watch(8) multiple times. Even though snp(4) will be dead as of next
week, it's nice having this in SVN, because:
- We may want to MFC it to RELENG_7.
- By the time we fix snp(4) again, it's already there, existing watch(8)
binaries should already work.
Just like bpf(4), I'm adding a symlink from snp0 to snp to remain binary
compatible.
due to the way watch(8) looks for available snoop devices.
PR: bin/118286
Submitted by: Mykola Zubach <zuborg@advancedhosters.com>
Reviewed by: rwatson, csjp, imp (all a long time ago)
Approved by: imp (mentor) (long time ago)
MFC after: 1 week
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)
_PATH_DEV will never change. In the un-likely event that _PATH_DEV
should ever change, watch(8) would have broke because of a
mis-generated device name.
Approved by: bmilekic (mentor)
Pointed out by: Yvan Boily
return for getopt() and comparing to -1, ditto with fgetc() and EOF,
and using the kg_nice value from <sys/user.h>
Submitted by: Stefan Farfeleder <stefan@fafoe.narf.at>
Reviewed by: obrien, bde (a while back)
Tested lightly on: ppc, i386, make universe
was never technically true (it's snp(4) that required root, not
watch(8)), and after snp.c 1.64, isn't even effectively true, since
who can run watch(8) depends on the permissions of the snp device(s).
Sort options in SYNOPSIS and DESCRIPTION while I'm here.
Previously, watch would always use the first device it could
successfully open, but this isn't always desired. Specifically, it
may not be desired during debugging (of snp), or if a particular snp
device has different permissions (which makes since after snp.c 1.64).
change terminals being watched. This change makes watch pass the
<control-X> through to the terminal if it's not being intercepted--
previously, the keypress would simply be dropped.
track.
The Id line is normally at the bottom of the main comment block in the
man page, separated from the rest of the manpage by an empty comment,
like so;
.\" $Id$
.\"
If the immediately preceding comment is a @(#) format ID marker than the
the $Id$ will line up underneath it with no intervening blank lines.
Otherwise, an additional blank line is inserted.
Approved by: bde
2. fix a potential buffer oflow,
3. makes watch(8) conform to sysexits(3).
Not a strong 2.2 candidate even if it would be nice.
Reviewed by: joerg, imp