History log of /freebsd-current/usr.sbin/watch/watch.c
Revision Date Author Comments
# 4d65a7c6 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.sbin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 33d72c30 20-Dec-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

Revert r327005 - SPDX tags for license similar to BSD-2-Clause.

After consultation with SPDX experts and their matching guidelines[1],
the licensing doesn't exactly match the BSD-2-Clause. It yet remains to be
determined if they are equivalent or if there is a recognized license that
matches but it is safer to just revert the tags.

Let this also be a reminder that on FreeBSD, SPDX tags are only advisory
and have no legal value (but IANAL).

Pointyhat to: pfg
Thanks to: Rodney Grimes, Gary O'Neall

[1] https://spdx.org/spdx-license-list/matching-guidelines


# d17aef79 19-Dec-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

SPDX: These are fundamentally BSD-2-Clause.

They just omit the introductory line and numbering.


# 9b10f59a 13-Dec-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

SPDX: mostly fixes to previous changes.

Introduce the recently approved BSD-1-Clause and replace 0BSD which
never did fit well our use cases.


# 8820ecc0 30-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

SPDX: Fix some cases wrongly attributed to MIT.

In the cases of BSD-style license variants without clauses, use 0BSD for
the time being in lack of a better description.


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# ec15b81b 06-Oct-2015 Xin LI <delphij@FreeBSD.org>

Use strlcpy() when the string is expected to be nul-terminated.

MFC after: 2 weeks


# 79e6a2c0 05-Sep-2013 Jilles Tjoelker <jilles@FreeBSD.org>

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
MFC after: 1 week


# 0ba64b27 10-Mar-2012 Ed Schouten <ed@FreeBSD.org>

Perform even more style changes.

- 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


# f1007076 10-Mar-2012 Ed Schouten <ed@FreeBSD.org>

Fix whitespace.

MFC after: 1 week


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 2e37c8ea 15-Aug-2008 Ed Schouten <ed@FreeBSD.org>

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.


# 868f9ca2 30-Jan-2008 Rink Springer <rink@FreeBSD.org>

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


# cb74d4b2 21-Sep-2005 Olivier Houchard <cognet@FreeBSD.org>

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


# 6ed0b39d 19-Sep-2005 Ruslan Ermilov <ru@FreeBSD.org>

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

Reviewed by: cognet


# b615d79f 18-Sep-2005 Olivier Houchard <cognet@FreeBSD.org>

Open the tty device and pass the fd for SNPSTTY.

MFC after: 3 days


# f8da56fd 09-Aug-2004 Christian S.J. Peron <csjp@FreeBSD.org>

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)


# 0f27b907 29-May-2004 Christian S.J. Peron <csjp@FreeBSD.org>

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


# 5cfe0423 22-Jan-2004 Peter Grehan <grehan@FreeBSD.org>

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


# b728350e 03-May-2003 David E. O'Brien <obrien@FreeBSD.org>

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


# ba964e50 11-Nov-2002 Thomas Moestl <tmm@FreeBSD.org>

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

Reviewed by: dd


# 2f92b79f 10-Aug-2002 Mike Heffner <mikeh@FreeBSD.org>

Add break's to case blocks.

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


# 48462fb1 11-Jun-2002 Warner Losh <imp@FreeBSD.org>

de __P
ANSI functions
minor knf


# 4c995cc6 24-Feb-2002 Bruce Evans <bde@FreeBSD.org>

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


# 1995d3a4 24-Nov-2001 Dima Dorfman <dd@FreeBSD.org>

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).


# 22f94a0a 07-Nov-2001 Robert Watson <rwatson@FreeBSD.org>

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.


# fc66e618 09-Sep-2001 Dima Dorfman <dd@FreeBSD.org>

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


# 8d43ce09 15-Jul-2001 Dima Dorfman <dd@FreeBSD.org>

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

Set WARNS=2.


# 1a37aa56 09-Dec-2000 David E. O'Brien <obrien@FreeBSD.org>

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


# 1e7ae6a9 23-Jan-2000 Philippe Charnier <charnier@FreeBSD.org>

Add missing .El.
-Wall cleaning.


# e46b89dc 14-Sep-1999 Peter Wemm <peter@FreeBSD.org>

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


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# dc763e50 26-Oct-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3).


# 6c3f552a 30-Mar-1997 Warner Losh <imp@FreeBSD.org>

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


# ac89160a 18-Mar-1997 Bruce Evans <bde@FreeBSD.org>

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


# 2bb69a48 13-Mar-1997 Ollivier Robert <roberto@FreeBSD.org>

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


# 33bdf4c4 30-Dec-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

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


# 7837dcf6 17-Dec-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

Use RAW, not CBREAK


# 5009d1be 01-Dec-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

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


# 47f8b1da 01-Mar-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

Properly save and restore the terminal characters!


# 020539b6 16-Dec-1995 Jordan K. Hubbard <jkh@FreeBSD.org>

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>


# 3e37ec67 26-Oct-1995 Andrey A. Chernov <ache@FreeBSD.org>

Add setlocale LC_TIME


# 8a9c3560 04-Aug-1995 Andrey A. Chernov <ache@FreeBSD.org>

Add missing ospeed initialization


# 709e8f9a 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# c1209799 27-Feb-1995 Ugen J.S. Antsilevich <ugen@FreeBSD.org>

same


# cb95dc24 25-Feb-1995 Paul Traina <pst@FreeBSD.org>

Update to use new calling conventions


# 7f4c7948 17-Feb-1995 Ugen J.S. Antsilevich <ugen@FreeBSD.org>

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] :)