History log of /freebsd-9.3-release/usr.sbin/watch/watch.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 255529 13-Sep-2013 jilles

MFC r255261: watch: Do not mess up the tty modes on early error.

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


# 233083 17-Mar-2012 ed

MFC r232780 and r232781:

Fix whitespace.


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 181755 15-Aug-2008 ed

Convert the snp(4) driver to use cdevpriv.

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.


# 175824 30-Jan-2008 rink

Allow watch(8) to use more than 10 snp* devices. This limitation was purely
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


# 150417 21-Sep-2005 cognet

Close the tty file descriptor once we're done with it.
Use O_NONBLOCK when opening the tty device.

Suggested by: bde
Submitted by: ru


# 150322 19-Sep-2005 ru

Restore the ability to detach from a tty via SIOCSTTY and document
recent changes in a manpage.

Reviewed by: cognet


# 150299 18-Sep-2005 cognet

Open the tty device and pass the fd for SNPSTTY.

MFC after: 3 days


# 133419 09-Aug-2004 csjp

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)


# 129849 29-May-2004 csjp

Remove constant which makes the assumption that the length of
_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


# 124830 22-Jan-2004 grehan

Userland signed char fixes for PPC build. Problems were using a char
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


# 114601 03-May-2003 obrien

Use __FBSDID over rcsid[]. Protect copyright[] where needed.


# 106769 11-Nov-2002 tmm

The FIONREAD sysctl operates on an int *, not a size_t *.

Reviewed by: dd


# 101636 10-Aug-2002 mikeh

Add break's to case blocks.

PR: bin/41511
Submitted by: Daniel Hagan <dhagan@acm.vt.edu>


# 98140 12-Jun-2002 imp

de __P
ANSI functions
minor knf


# 91229 25-Feb-2002 bde

#include <time.h> for the definition of time functions instead of
depending on namespace pollution 2 layers deep in <sys/stat.h>.


# 86858 24-Nov-2001 dd

Add an -f option which allows one to specify a snp device to use.
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).


# 86169 07-Nov-2001 rwatson

o When "-n" is used with watch, it disables the use of <control-X> to
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.


# 83249 09-Sep-2001 dd

Automatically load the "snp" module if it isn't already present.


# 79759 15-Jul-2001 dd

Add prototypes, staticize, constify, don't shadow global variables and
functions, remove an unused function, and silence other assorted
warnings.

Set WARNS=2.


# 69793 09-Dec-2000 obrien

Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.


# 56489 23-Jan-2000 charnier

Add missing .El.
-Wall cleaning.


# 51287 14-Sep-1999 peter

Fix warning: return type of `main' is not `int'


# 50479 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 30773 27-Oct-1997 charnier

Use err(3).


# 24428 31-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 24035 19-Mar-1997 bde

Removed old bogus prerequisite <sys/select.h>. Cleaned up #include mess.


# 23837 13-Mar-1997 roberto

1. change tty handling from sgttyb to termios,
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


# 21048 30-Dec-1996 jkh

Remove breakage of 1.8.2.2, choose slightly better character for quit.


# 20595 17-Dec-1996 jkh

Use RAW, not CBREAK


# 20085 02-Dec-1996 jkh

I have added a '-n' flag to the watch(8) command. This option
disables the ability to interactively select a new tty. I have also
removed a check for uid == 0 because it gets in the way of using suid
mode based access control. Watch (8)is only runnable by root, so this
does not really change things much.

Closes PR#2131

Submitted-By: adrian@virginia.edu


# 14310 01-Mar-1996 jkh

Properly save and restore the terminal characters!


# 12887 16-Dec-1995 jkh

Map ^C and ^\ (INTR and QUIT) to ^Q so that you can actually send these
guys to a watched process. Useful if you're monitoring someone who's
started doing something you'd really like them to stop immediately. :)
Suggested by: Phillip White <philw@megasoft.tic.ab.ca>


# 11828 26-Oct-1995 ache

Add setlocale LC_TIME


# 9895 04-Aug-1995 ache

Add missing ospeed initialization


# 8857 30-May-1995 rgrimes

Remove trailing whitespace.


# 6775 27-Feb-1995 ugen

same


# 6713 25-Feb-1995 pst

Update to use new calling conventions


# 6521 17-Feb-1995 ugen

This is watch - programm to work with /dev/snp,
it still lacks manpage-i will commit it today later.
For now to test try: watch [ttyname] :)