[syslog-ng] [PATCH] logreader: When following a file, treat non-regular files specially

Gergely Nagy algernon at balabit.hu
Fri Oct 5 12:50:29 CEST 2012


When following a file with follow-freq(), and it is not a regular
file, but something for which stat(2) always returns 0 size (such as
the /dev/klog character device on FreeBSD),
log_reader_io_follow_file() never went into the process input branch,
because the current position (0) was always at EOF (also 0).

To break out of this unfortunate situation, if the file to read from
is not a regular file, go into the process input loop anyway: at
worst, it will do an expensive noop.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 lib/logreader.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/logreader.c b/lib/logreader.c
index eb52330..1e2ea5e 100644
--- a/lib/logreader.c
+++ b/lib/logreader.c
@@ -276,7 +276,7 @@ log_reader_io_follow_file(gpointer s)
                 evt_tag_int("size", st.st_size),
                 NULL);
 
-      if (pos < st.st_size)
+      if (pos < st.st_size || !S_ISREG(st.st_mode))
         {
           /* we have data to read */
           log_reader_io_process_input(s);
-- 
1.7.10.4




More information about the syslog-ng mailing list