[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tail: avoid rare error-path FD leak
From: |
Jim Meyering |
Subject: |
[PATCH] tail: avoid rare error-path FD leak |
Date: |
Thu, 02 Aug 2012 16:52:42 +0200 |
FYI,
>From 81806035310c5c16b1b11c88709bf066305ed160 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 27 Jul 2012 23:42:05 +0200
Subject: [PATCH] tail: avoid rare error-path FD leak
* src/tail.c (tail_forever): Close FD to avoid leak after a
failed fstat.
---
src/tail.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/tail.c b/src/tail.c
index 1935605..290ada4 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1139,10 +1139,11 @@ tail_forever (struct File_spec *f, size_t n_files,
double sleep_interval)
if (fstat (fd, &stats) != 0)
{
f[i].fd = -1;
f[i].errnum = errno;
error (0, errno, "%s", name);
+ close (fd); /* ignore failure */
continue;
}
if (f[i].mode == stats.st_mode
&& (! S_ISREG (stats.st_mode) || f[i].size == stats.st_size)
--
1.7.12.rc1.10.g97c7934
- [PATCH] tail: avoid rare error-path FD leak,
Jim Meyering <=