diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-03-12 19:40:06 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-03-12 19:40:06 +0000 |
commit | e5a3f1d744e3512e5cf3f4ffeb7e915d14763e86 (patch) | |
tree | 784b1363a2765f37e4136d1427dc92f89bece53a /usr.bin/tail/forward.c | |
parent | 1bb341f6049b0185472c50d7fda0f516c6de6329 (diff) |
If kqueue is not available, revert back to old behavior. Unbreaks tail -f
on NFS and other filesystems not supporting kqueues.
ok tedu@ millert@
Diffstat (limited to 'usr.bin/tail/forward.c')
-rw-r--r-- | usr.bin/tail/forward.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c index 2d319f33ad2..8e5521007f4 100644 --- a/usr.bin/tail/forward.c +++ b/usr.bin/tail/forward.c @@ -1,4 +1,4 @@ -/* $OpenBSD: forward.c,v 1.19 2004/03/01 16:35:05 otto Exp $ */ +/* $OpenBSD: forward.c,v 1.20 2004/03/12 19:40:05 otto Exp $ */ /* $NetBSD: forward.c,v 1.7 1996/02/13 16:49:10 ghudson Exp $ */ /*- @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)forward.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: forward.c,v 1.19 2004/03/01 16:35:05 otto Exp $"; +static char rcsid[] = "$OpenBSD: forward.c,v 1.20 2004/03/12 19:40:05 otto Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -89,7 +89,7 @@ forward(fp, style, off, sbp) { int ch; struct stat nsb; - int kq; + int kq, queue; struct kevent ke; switch(style) { @@ -206,7 +206,9 @@ kq_retry: if (!fflag) break; clearerr(fp); + queue = 1; if (kq < 0 || kevent(kq, NULL, 0, &ke, 1, NULL) <= 0) { + queue = 0; sleep(1); } else if (ke.filter == EVFILT_READ) { continue; @@ -235,7 +237,8 @@ kq_retry: } (void)memcpy(sbp, &nsb, sizeof(nsb)); goto kq_retry; - } else if (ke.fflags & NOTE_TRUNCATE) { + } else if ((queue && (ke.fflags & NOTE_TRUNCATE)) || + (!queue && nsb.st_size < sbp->st_size)) { warnx("%s has been truncated, resetting.", fname); fpurge(fp); rewind(fp); |