summaryrefslogtreecommitdiff
path: root/src/tail.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-07-25 18:35:36 +0200
committerJim Meyering <meyering@redhat.com>2012-07-25 19:00:22 +0200
commita6e8e3a3e116f2cdaa452eb66032d912092d0026 (patch)
tree9098d8c0e60b79ae0cccb0a3217d248a77fcbf94 /src/tail.c
parentd75e93cb76c504e766e317ea0891285e4510ae67 (diff)
downloadcoreutils-a6e8e3a3e116f2cdaa452eb66032d912092d0026.tar.xz
tail: avoid misleading diagnostic upon fstat failure
* src/tail.c (check_fspec): Save fstat-induced errno *before* calling close_fd, not after. Otherwise, the close could well clobber the global errno, making tail print an invalid diagnostic. This could happen only with tail -f, and even then, only when a valid file descriptor were to provoke fstat failure.
Diffstat (limited to 'src/tail.c')
-rw-r--r--src/tail.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tail.c b/src/tail.c
index 29ddabd62..1935605ef 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1276,9 +1276,9 @@ check_fspec (struct File_spec *fspec, int wd, int *prev_wd)
if (fstat (fspec->fd, &stats) != 0)
{
+ fspec->errnum = errno;
close_fd (fspec->fd, name);
fspec->fd = -1;
- fspec->errnum = errno;
return;
}