crash reporter: avoid repeated warning collection

The warning collector daemon parses the entire syslog every time it
starts (almost exclusively at boot).  This change makes the collector
start reading at the end of /var/log/messages (where it waits for further
input) rather than the beginning.  The collector will miss any warnings
that may have occurred between the last warning reported, and the daemon
restart.

BUG=chromium:343954
TEST=none yet
BRANCH=none

Change-Id: I5e9b141561365b9a1d328ed6283c27e8b3369a6f
Reviewed-on: https://chromium-review.googlesource.com/186605
Reviewed-by: Grant Grundler <grundler@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
diff --git a/crash_reporter/warn_collector.l b/crash_reporter/warn_collector.l
index 6411b4d..691ef99 100644
--- a/crash_reporter/warn_collector.l
+++ b/crash_reporter/warn_collector.l
@@ -160,6 +160,13 @@
   if (yyin_fd < 0)
     Die("could not open %s: %s\n", path, strerror(errno));
   if (!fifo) {
+    /* Go directly to the end of the file.  We don't want to parse the same
+     * warnings multiple times on reboot/restart.  We might miss some
+     * warnings, but so be it---it's too hard to keep track reliably of the
+     * last parsed position in the syslog.
+     */
+    if (lseek(yyin_fd, 0, SEEK_END) < 0)
+      Die("could not lseek %s: %s\n", path, strerror(errno));
     /* Set up notification of file growth and rename. */
     i_fd = inotify_init();
     if (i_fd < 0)