summaryrefslogtreecommitdiff
path: root/sys/src/cmd/tail.c
diff options
context:
space:
mode:
authorftrvxmtrx <devnull@localhost>2014-05-08 14:29:44 +0200
committerftrvxmtrx <devnull@localhost>2014-05-08 14:29:44 +0200
commit7ea0732c554f65ee52af30c8f6d601e1ba4ee034 (patch)
tree93fe07a359ea1f49e0fed81e4af594b42e650c4b /sys/src/cmd/tail.c
parent1c835e370ff58e58b75c12a9e743a2bb33d84cb0 (diff)
tail: fix follow for empty files (thanks cinap_lenrek)
Diffstat (limited to 'sys/src/cmd/tail.c')
-rw-r--r--sys/src/cmd/tail.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/src/cmd/tail.c b/sys/src/cmd/tail.c
index 572224749..e8717dc50 100644
--- a/sys/src/cmd/tail.c
+++ b/sys/src/cmd/tail.c
@@ -8,6 +8,7 @@
* the simple command tail -c, legal in v10, is illegal
*/
+vlong fend;
long count;
int anycount;
int follow;
@@ -111,7 +112,7 @@ main(int argc, char **argv)
else
if(units==LINES && origin==BEG)
skip();
- if(follow && seekable)
+ if(follow && (seekable || fend == 0))
for(;;) {
static Dir *sb0, *sb1;
trunc(sb1, &sb0);
@@ -368,5 +369,6 @@ usage(void)
static int
isseekable(int fd)
{
- return seek(fd, 0, 2) > 0 && seek(fd, 0, 0) == 0;
+ fend = seek(fd, 0, 2);
+ return fend > 0 && seek(fd, 0, 0) == 0;
}