]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/tail.c
libregexp: improve the transition to next available thread, instruction, and generation
[plan9front.git] / sys / src / cmd / tail.c
index 5f328af697d60367304a7f71d468c081d4c05f8e..e8717dc50b4461a847be987eefd226b107825a0f 100644 (file)
@@ -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);
@@ -365,17 +366,9 @@ usage(void)
        exits("usage");
 }
 
-/* return true if seeks work and if the file is > 0 length.
- * this will eventually bite me in the ass if seeking a file
- * is not conservative. - presotto
- */
 static int
 isseekable(int fd)
-{      
-       vlong m;
-
-       m = seek(fd, 0, 1);
-       if(m < 0)
-               return 0;
-       return 1;
+{
+       fend = seek(fd, 0, 2);
+       return fend > 0 && seek(fd, 0, 0) == 0;
 }