Commit Graph

33 Commits

Author SHA1 Message Date
christos 472bcd2198 PR/50322: Timo Buhrmester: tail -F <file> misbehaves with stdin closed
Compare fp with stdin not fileno(fp) with STDIN_FILENO, because if tail
is called with 0 closed, then we are not going to be setting event filters
for the file because we'll erroneously think it is stdin.
2015-10-09 17:51:26 +00:00
christos 6e28978d84 fix unused variable warnings 2013-10-18 20:47:06 +00:00
christos d44b4781e6 minor knf, no functional change. 2011-09-03 10:59:10 +00:00
christos 56b933f4a2 Instead of declaring our own err() which is different than the standard one,
and using it incorrectly in a few places because of confusion (does it print
errno or not?), declare two versions following the standard ones xerrx and,
xerr, and use those as appropriate, implementing them using them vwarn and
vwarnx.
2011-09-03 09:02:20 +00:00
lukem 0980aab530 Fix WARNS=4 issues (-Wcast-qual -Wshadow -Wsign-compare)
XXX: need a "cleaner" way to do the check in reverse.c, as a general rule
2009-04-13 23:33:25 +00:00
christos a740c3d0aa Coverity CID 3204: The USE_SLEEP case can close the fp, and break does
not break from the loop, only from the switch. Make it break from the
loop to avoid a NULL pointer dereference.
2006-05-24 16:34:25 +00:00
lukem ef45472693 appease gcc -Wuninitialized 2005-06-02 03:00:19 +00:00
itojun 7551fb024f do not use long for file offset, use off_t. otto@openbsd 2004-02-16 21:57:04 +00:00
agc 89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
lukem 8bfad4ad7a Use sleep(1) instead of usleep(1000000) to sleep for a second, since
usleep() doesn't support an argument >= 1000000.
Problem noted & fix provided in [bin/20644] from Dave Huang.
2003-03-10 08:04:15 +00:00
jdolecek 64275c4aaf use kqueue to watch the file if possible
from FreeBSD via Luke Mewburn

this specifically does NOT include FreeBSD rev. 1.28 change; it's
my understanding -F is specifically meant to only detect removal
of the tailed file, not to watch for intermediate path changes
2002-10-30 21:48:50 +00:00
skrll 5152db4b16 Update error message after recent changes. 2002-09-18 19:29:12 +00:00
mycroft 855996c546 Remove an old comment. 2002-09-18 19:21:41 +00:00
mycroft 1bf9916dae select() -> nanosleep() 2002-09-18 19:14:58 +00:00
wiz 3c4c9d2b57 Remove #if __STDC__. De-__P() and ANSIfy. 2002-06-14 00:41:42 +00:00
explorer 78762d72a5 fix tail; don't try to map more of the file than really exists 2001-11-24 02:30:17 +00:00
explorer a3c923dc72 make tail -f and tail -10000 work on files > those which can be mmap()ed whole. tail -r will still not function on large files. 2001-11-21 06:47:07 +00:00
cgd b02d81404c avoid repeated error messages by making bytes(), lines() and rlines() return
meaningful values, which can then be checked to avoid another error message.
1999-07-21 06:38:49 +00:00
christos eb4463abfe KNF 1998-12-19 22:27:54 +00:00
christos 8d721633cd Pacify gcc-2.8.1 (extra braces). 1998-11-03 14:26:45 +00:00
cjs 59a47ce7be Remove tracking of file size by how many characters were output.
This succumbs to a race condition where data are written to the
file while the sleep is occurring. If a stat is done immediately
after, lastsize is updated but the file pointer wasn't pointing at
the end of the file, so the number of bytes between the current
pointer and the end of the file is added to the lastsize when
lastsize already points to the end of the file.
1998-09-18 01:42:54 +00:00
mycroft 8f2250049f Use MAP_SHARED, not MAP_PRIVATE. 1998-02-20 07:34:59 +00:00
augustss 170f7ea829 Add MAP_FILE as well. 1998-02-17 17:44:55 +00:00
augustss f9cd93c874 Make sure mmap() uses MAP_PRIVATE instead of 0. 1998-02-17 17:40:59 +00:00
cjs 4d03919ab5 Add -F option to follow files though rotations and truncations. 1998-02-09 22:39:41 +00:00
lukem 079884da30 WARNSify, fix .Nm usage, deprecate register, getopt returns -1 not EOF 1997-10-19 23:45:08 +00:00
ghudson bd8bd7340f Don't rely on select() not to modify the timeval argument. Also,
simplify the code by passing in NULL rather than an empty fd_set to
indicate no file descriptors.
1996-02-13 16:49:10 +00:00
jtc ae646d0e62 Merged with 4.4lite.
Changed to conform to NetBSD's new RCS Id convention.
1994-11-23 07:41:55 +00:00
jtc 48851c7a0b munmap() mmap()ed regions. 1994-11-23 07:11:00 +00:00
deraadt 907eea9f85 various off_t fixes 1994-04-24 20:19:17 +00:00
cgd ceacf6a332 off_t foo, and MAP_FILE 1994-03-28 02:22:29 +00:00
mycroft e9d867ef50 Add RCS identifiers. 1993-08-01 17:54:45 +00:00
glass aa97860f48 tail from ftp.uu.net:bsd-sources integrated 1993-04-30 08:04:52 +00:00