Commit Graph

48 Commits

Author SHA1 Message Date
dwmalone
ec9302ee87 Fix up vendor IDs.
Put a sequence point between writing to a variable and using it.
2002-04-13 20:59:48 +00:00
murray
cc26525bb5 GCC 3.1 cleanup - add a break after default: at the end of a switch
statement.
2002-04-08 08:34:00 +00:00
imp
0b20191705 remove __P 2002-03-22 01:42:45 +00:00
markm
d7e4e2a006 WARNS=2 fixes, use __FBSDID(). 2001-12-12 00:01:16 +00:00
iedowse
f9343b3578 Since kqueue support was added to tail, the "-F" option (check for
renames/rotations) only detected cases where the file itself was
moved or deleted. If part of the path to the file (or a symlink
in the path) was changed instead, tail would not notice.

Fix this by ensuring that we stat the path at least once every
second in the -F case to check for changes. We still use kqueue
when possible to inform us quickly when the file has changed.

PR:		bin/24955
Submitted by:	Maxim Konovalov <maxim@macomnet.ru>
MFC after:	1 week
2001-11-25 18:03:28 +00:00
fenner
efade0125d Allow "obsolete" (but commonly-used) command line style to be used
with -F, e.g. tail -1 -F /var/log/messages.

Submitted by:	Maxim Konovalov <maxim@macomnet.ru>
2001-10-02 06:22:01 +00:00
ache
46ab006323 File positions are off_t nowdays, not long, so:
long -> off_t
strtol -> strtoll
fseek -> fseeko

NOTE: that fseek not works for >long offsets files per POSIX:

[EOVERFLOW] For fseek( ), the resulting file offset would be a value which
cannot be represented correctly in an object of type long.
2001-09-01 22:22:45 +00:00
ru
bde8ec1b70 mdoc(7) police: utilize the new .Ex macro. 2001-08-15 09:09:47 +00:00
ru
36f138439b mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 14:16:33 +00:00
jlemon
08bbb9b6f5 o If the file being tailed is moved back to the original location,
resume using kqueue to monitor it, if possible.
  o auto-clear the read filter on EOF; this is needed when tailing a FIFO.
2001-06-06 17:47:13 +00:00
ache
323ee87c02 Back out my fseeko -> fseek(END) change - we need to position on what we
displayed last, not to the end of file
2001-03-28 13:10:17 +00:00
ache
b3c7f151dc Restore part of my fix spammed in v1.23:
fseeko(file_size, SEEK_SET) -> fseek(0L, SEEK_END)
1) File may grows between operations, so fseeko to file_size may miss
2) 0L, SEEK_END is the same code using in tail in all other places
2001-03-27 23:24:25 +00:00
dwmalone
17ede005a9 Fix tail to work on files bigger than 2GB.
PR:		14786
Reviewed by:	iedowse
2001-03-27 20:37:34 +00:00
ache
aec4c6204b Add comment explaining why size not passed directly to mmap, i.e. not relay
on its check.
KNF multi-line comments
(inspired by bde)
2001-03-27 15:53:48 +00:00
ache
8a3f432b98 Use SSIZE_MAX instead of INT_MAX, as kernel does ssize_t check
Better explanation comment of FIXME section
2001-03-27 01:16:44 +00:00
ache
5b94e50e9a Treat mmap() error as fatal too, i.e. do exit(1) instead of return 2001-03-26 19:36:27 +00:00
ache
f087b10f53 rlines() checks:
1) really check for size overflow by checking negative value.
2) since mmap() not support files over INT_MAX size, add check for it
until either mmap() will be fixed or tail will be rewritted to handle
large files alternatively.
3) replace fseek(... file_size, SEEK_SET) with fseek(... 0L, SEEK_END)
to avoid off_t -> long cast
4) Use exit() if file is too big instead of warning and wrong logic
afterwards.
2001-03-26 19:29:49 +00:00
jlemon
15e59884c9 Use EV_SET() macro to initialize kevent structure. 2001-02-28 16:16:31 +00:00
ru
5038154904 Mention the -F in the usage().
PR:		24586
Submitted by:	Cyrille Lefevre <clefevre@citeweb.net>
2001-01-24 08:27:59 +00:00
asmodai
2bf21fac09 Remove register keyword usage with prejudice.
Modern compilers are smarter when it comes to allocating register
usage.
2000-12-03 17:05:45 +00:00
asmodai
33a20c676d Use a size_t instead of an int. 2000-12-02 20:21:13 +00:00
asmodai
85f201535e Properly constify some static arrays.
Also #if out some sccsid's and add rcsid's.
2000-12-02 19:10:12 +00:00
ru
0d1334ca0c mdoc(7) police: use the new features of the Nm macro. 2000-11-20 19:21:22 +00:00
jlemon
d7b89f0457 Convert calls to match new kqueue API. 2000-07-18 19:38:38 +00:00
jlemon
ad3e80ef8d If the kevent() registration fails (probably due to the underlying
filesystem not being kq-aware), then fall back to using sleep.  This
allows tail to work with NFS filesystems again without chewing up CPU time.

When given the -F flag, resort to sleep/stat after the file was moved
or deleted.  This allows a window where the file being tailed does not
exist at all, which is typically the case during log rotation.  Switch
back to using kq (if possible) after the file is reopened.
2000-06-22 18:46:03 +00:00
jlemon
d8e2bb35d5 Change <event.h> --> <sys/event.h> 2000-04-18 16:56:55 +00:00
jlemon
60301c6348 Change tail to use kqueue/kevent to obtain a notification when
the file changes (when doing tail -{f|F}).
2000-04-16 19:04:49 +00:00
charnier
42d5955dc9 Add DIAGNOSTICS section name 2000-03-26 15:06:46 +00:00
peter
3b842d34e8 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
nik
6578739ddb Add $Id$, to make it simpler for members of the translation teams to
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
1999-07-12 20:24:20 +00:00
billf
4822432874 Clean up some ambiguous nested if/elses. 1999-07-04 17:26:16 +00:00
bde
0609531ab6 Fixed printf format errors. 1998-07-06 21:01:54 +00:00
peter
7c3222498a Add a new -F flag which is a superset of -f. It will cause tail to
stat() the file being followed and do a close/reopen if the file has been
renamed and/or rotated.  This is damn useful for leaving running on files
in /var/log when newsyslog(8) rotates them.
1998-04-06 16:13:49 +00:00
ache
4fe5164a59 Change select(0, NULL, ...) to usleep() 1997-12-12 11:47:28 +00:00
phk
045b39ade8 Fix a misleading comment. Rename a variable to make more sense.
Pointed out by by:	 bde
1997-10-11 07:32:43 +00:00
phk
a44ef51975 Fix a comment.
Submitted by:		Mikael Karpberg <karpen@ocean.campus.luth.se>
1997-09-15 08:20:27 +00:00
phk
a4e52dd09b In these days, waiting one full second for more to appear is far too long.
Let's try 250ms.
1997-09-14 19:02:13 +00:00
charnier
cf4900f7ab Remove trailing \n in warn() string. 1997-08-13 06:46:57 +00:00
imp
141381e1cb compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
alex
a3118e8c68 Sweep through the tree fixing mmap() usage:
- Use MAP_FAILED instead of the constant -1 to indicate
    failure (required by POSIX).
  - Removed flag arguments of '0' (required by POSIX).
  - Fixed code which expected an error return of 0.
  - Fixed code which thought any address with the high bit set
    was an error.
  - Check for failure where no checks were present.

Discussed with:	bde
1997-01-16 21:58:40 +00:00
adam
794f8a0f1c complete err() changes, actually use warn() in most instances 1996-08-26 20:37:48 +00:00
peter
64c12fd60d Dont forget to #include <err.h> 1996-08-25 21:14:19 +00:00
peter
a5eafc88c5 Argh! caught! *blush*.. This program was supplying it's own 'err' routine
which was slightly different to the libc one.  To save any more cunfusion,
use the libc one.
1996-08-25 21:12:01 +00:00
peter
72cf92af79 Fix some bogons:
- timeval in select loop was depending on not having the remaining time
  returned from select(), causing a busy spin on an implementation that
  does implement it.
- the err() usage was pretty bogus, some of the error messages had
  strerror attached manually and then reattached by err().
1996-08-25 21:03:50 +00:00
adam
e46c6e5f4a one file somehow slipped by me in the previous commit
tidy up
1996-07-30 15:44:30 +00:00
adam
e46b438575 when file can be opened for read but cannot be read from:
fail once (was twice) in forward case
fail once (was no times) in reverse case

this can happen when file is a directory on an NFS or procfs mount.
1996-07-30 13:11:43 +00:00
phk
0c24d9d5ce Another program depending on zero'ed malloc.
Submitted by:	Kai Vorma <vode@snakemail.hut.fi>
1995-10-10 10:03:48 +00:00
rgrimes
f9ab90d9d6 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00