Commit Graph

41 Commits

Author SHA1 Message Date
Pedro F. Giffuni
1de7b4b805 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.
2017-11-27 15:37:16 +00:00
Xin LI
ec15b81be1 Use strlcpy() when the string is expected to be nul-terminated.
MFC after:	2 weeks
2015-10-06 22:49:25 +00:00
Jilles Tjoelker
79e6a2c01e 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
2013-09-05 19:02:03 +00:00
Ed Schouten
0ba64b2731 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
2012-03-10 14:38:34 +00:00
Ed Schouten
f10070765a Fix whitespace.
MFC after:	1 week
2012-03-10 14:35:09 +00:00
Ed Schouten
2e37c8eacb 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.
2008-08-15 13:07:07 +00:00
Rink Springer
868f9ca26a 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
2008-01-30 13:55:32 +00:00
Olivier Houchard
cb74d4b2b4 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
2005-09-21 14:30:14 +00:00
Ruslan Ermilov
6ed0b39d28 Restore the ability to detach from a tty via SIOCSTTY and document
recent changes in a manpage.

Reviewed by:	cognet
2005-09-19 13:48:45 +00:00
Olivier Houchard
b615d79f9b Open the tty device and pass the fd for SNPSTTY.
MFC after:	3 days
2005-09-18 19:24:05 +00:00
Christian S.J. Peron
f8da56fda8 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)
2004-08-10 01:49:46 +00:00
Christian S.J. Peron
0f27b90770 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
2004-05-29 21:03:00 +00:00
Peter Grehan
5cfe0423e6 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
2004-01-22 07:23:36 +00:00
David E. O'Brien
b728350ee6 Use __FBSDID over rcsid[]. Protect copyright[] where needed. 2003-05-03 21:06:42 +00:00
Thomas Moestl
ba964e50b0 The FIONREAD sysctl operates on an int *, not a size_t *.
Reviewed by:	dd
2002-11-11 10:56:57 +00:00
Mike Heffner
2f92b79ff6 Add break's to case blocks.
PR:		bin/41511
Submitted by:	Daniel Hagan <dhagan@acm.vt.edu>
2002-08-10 08:42:10 +00:00
Warner Losh
48462fb1b7 de __P
ANSI functions
minor knf
2002-06-12 04:28:15 +00:00
Bruce Evans
4c995cc66e #include <time.h> for the definition of time functions instead of
depending on namespace pollution 2 layers deep in <sys/stat.h>.
2002-02-25 05:31:49 +00:00
Dima Dorfman
1995d3a484 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).
2001-11-24 15:41:38 +00:00
Robert Watson
22f94a0a16 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.
2001-11-07 19:15:19 +00:00
Dima Dorfman
fc66e618b4 Automatically load the "snp" module if it isn't already present. 2001-09-09 14:57:48 +00:00
Dima Dorfman
8d43ce09fc Add prototypes, staticize, constify, don't shadow global variables and
functions, remove an unused function, and silence other assorted
warnings.

Set WARNS=2.
2001-07-15 11:03:28 +00:00
David E. O'Brien
1a37aa566b Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.
2000-12-09 09:35:55 +00:00
Philippe Charnier
1e7ae6a9af Add missing .El.
-Wall cleaning.
2000-01-23 20:27:32 +00:00
Peter Wemm
e46b89dc93 Fix warning: return type of main' is not int' 1999-09-15 01:58:44 +00:00
Peter Wemm
97d92980a9 $Id$ -> $FreeBSD$ 1999-08-28 01:35:59 +00:00
Philippe Charnier
dc763e50ee Use err(3). 1997-10-27 12:21:10 +00:00
Warner Losh
6c3f552a31 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-31 05:11:47 +00:00
Bruce Evans
ac89160a93 Removed old bogus prerequisite <sys/select.h>. Cleaned up #include mess. 1997-03-19 04:44:07 +00:00
Ollivier Robert
2bb69a4847 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
1997-03-13 08:35:45 +00:00
Jordan K. Hubbard
33bdf4c4ae Remove breakage of 1.8.2.2, choose slightly better character for quit. 1996-12-30 09:01:50 +00:00
Jordan K. Hubbard
7837dcf615 Use RAW, not CBREAK 1996-12-17 15:26:40 +00:00
Jordan K. Hubbard
5009d1be3c 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
1996-12-02 12:32:46 +00:00
Jordan K. Hubbard
47f8b1da86 Properly save and restore the terminal characters! 1996-03-01 18:21:41 +00:00
Jordan K. Hubbard
020539b659 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>
1995-12-16 10:07:10 +00:00
Andrey A. Chernov
3e37ec674d Add setlocale LC_TIME 1995-10-26 23:15:14 +00:00
Andrey A. Chernov
8a9c356059 Add missing ospeed initialization 1995-08-04 07:17:24 +00:00
Rodney W. Grimes
709e8f9ae1 Remove trailing whitespace. 1995-05-30 03:57:47 +00:00
Ugen J.S. Antsilevich
c120979990 same 1995-02-27 19:48:19 +00:00
Paul Traina
cb95dc2435 Update to use new calling conventions 1995-02-25 20:14:31 +00:00
Ugen J.S. Antsilevich
7f4c79484b 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] :)
1995-02-17 14:36:03 +00:00