# define OFF_T_MAX TYPE_MAXIMUM (off_t)
#endif
-/* Disable assertions. Some systems have broken assert macros. */
-#define NDEBUG 1
-
#define XWRITE(fd, buffer, n_bytes) \
do \
{ \
} \
while (0)
-#define CLOSE_FD(Fd, Name) \
- do \
- { \
- if ((Fd) != -1 && (Fd) != STDIN_FILENO && close (Fd)) \
- { \
- error (0, errno, "closing %s (fd=%d)", (Name), (Fd)); \
- } \
- } \
- while (0)
-
-
/* Number of items to tail. */
#define DEFAULT_N_LINES 10
ino_t ino;
/* FIXME: describe */
- unsigned int no_change_counter;
+ unsigned int n_stat_calls;
+
+ /* FIXME: describe */
+ unsigned int n_unchanged_stats;
/* FIXME: describe */
int missing;
multiple_files, always, never
};
-/* FIXME: rename, document, and use this -- add option */
-static unsigned long max_no_change_count = 5;
+/* FIXME: describe -- add option */
+static unsigned long max_n_unchanged_stats = 5;
/* The name this program was run with. */
char *program_name;
exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
+static __inline__ void
+close_fd (int fd, const char *filename)
+{
+ if (fd != -1 && fd != STDIN_FILENO && close (fd))
+ {
+ error (0, errno, _("closing %s (fd=%d)"), filename, fd);
+ }
+}
+
static void
write_header (const char *pretty_filename, const char *comment)
{
if (fail)
{
- CLOSE_FD (fd, f->pretty_name);
- CLOSE_FD (f->fd, f->pretty_name);
+ close_fd (fd, f->pretty_name);
+ close_fd (f->fd, f->pretty_name);
f->fd = -1;
}
else if (f->ino != new_stats.st_ino || f->dev != new_stats.st_dev)
{
/* Close the old one. */
- CLOSE_FD (f->fd, f->pretty_name);
+ close_fd (f->fd, f->pretty_name);
/* File has been replaced (e.g., via log rotation) --
tail the new one. */
f->size = new_stats.st_size;
f->dev = new_stats.st_dev;
f->ino = new_stats.st_ino;
- f->no_change_counter = 0;
+ f->n_unchanged_stats = 0;
/* FIXME: check lseek return value */
lseek (f->fd, new_stats.st_size, SEEK_SET);
}
f->size = new_stats.st_size;
f->dev = new_stats.st_dev;
f->ino = new_stats.st_ino;
- f->no_change_counter = 0;
+ f->n_unchanged_stats = 0;
/* FIXME: check lseek return value */
lseek (f->fd, new_stats.st_size, SEEK_SET);
}
else
{
- CLOSE_FD (fd, f->pretty_name);
+ close_fd (fd, f->pretty_name);
}
}
if (stats.st_size == f[i].size)
{
- if (++f[i].no_change_counter > max_no_change_count
+ if (++f[i].n_unchanged_stats > max_n_unchanged_stats
&& follow_mode == follow_name)
{
recheck (&f[i]);
- f[i].no_change_counter = 0;
+ f[i].n_unchanged_stats = 0;
}
continue;
any_changed = 1;
/* reset counter */
- f[i].no_change_counter = 0;
+ f[i].n_unchanged_stats = 0;
if (stats.st_size < f[i].size)
{
}
if (errors)
{
- CLOSE_FD (fd, f->pretty_name);
+ close_fd (fd, f->pretty_name);
f->fd = -1;
}
else
f->size = stats.st_size;
f->dev = stats.st_dev;
f->ino = stats.st_ino;
- f->no_change_counter = 0;
+ f->n_unchanged_stats = 0;
}
}
else