diff --git a/src/cmd/tail.c b/src/cmd/tail.c index 68f7c5eb8..335c4ff80 100644 --- a/src/cmd/tail.c +++ b/src/cmd/tail.c @@ -44,6 +44,7 @@ extern void trunc(Dir*, Dir**); extern vlong tseek(vlong, int); extern void twrite(char*, long); extern void usage(void); +static int isseekable(int); #define JUMP(o,p) tseek(o,p), copy() @@ -92,7 +93,7 @@ main(int argc, char **argv) usage(); if(argc > 1 && (file=open(argv[1],0)) < 0) fatal(argv[1]); - seekable = seek(file,0L,0) == 0; + seekable = isseekable(file); if(!seekable && origin==END) keep(); @@ -361,3 +362,9 @@ usage(void) fprint(2, "%s\n", umsg); exits("usage"); } + +static int +isseekable(int fd) +{ + return seek(fd, 0, 2) > 0 && seek(fd, 0, 0) == 0; +}