bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tail -- close fd on a fstat failure


From: Giuseppe Scrivano
Subject: [PATCH] tail -- close fd on a fstat failure
Date: Sat, 30 May 2009 21:52:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux)

Hi,

I noticed that the fd is not closed properly if the fstat call fails.
This trivial patch solves it.

Giuseppe

>From 0f93ba2a0673a689bbeaf747b876f6f8c4bc6cae Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <address@hidden>
Date: Sat, 30 May 2009 21:41:26 +0200
Subject: [PATCH] tail: don't leave open fd when fstat fails.

* src/tail.c (tail_forever): close the fd before overwrite it.
---
 src/tail.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/tail.c b/src/tail.c
index fe34600..3ec896a 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1033,6 +1033,7 @@ tail_forever (struct File_spec *f, int nfiles, double 
sleep_interval)
            {
              if (fstat (fd, &stats) != 0)
                {
+                 close_fd (f[i].fd, pretty_name (f));
                  f[i].fd = -1;
                  f[i].errnum = errno;
                  error (0, errno, "%s", name);
-- 
1.6.3.1







reply via email to

[Prev in Thread] Current Thread [Next in Thread]