From a8733a8867805e83890469f591025f396d77e20e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 11 Aug 2009 15:22:35 +0200 Subject: [PATCH] tailf: report inotify_add_watch() problems Signed-off-by: Karel Zak --- text-utils/tailf.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/text-utils/tailf.c b/text-utils/tailf.c index e44fc098..6a76ef45 100644 --- a/text-utils/tailf.c +++ b/text-utils/tailf.c @@ -141,12 +141,22 @@ watch_file_inotify(const char *filename, off_t *size) return 0; ffd = inotify_add_watch(fd, filename, EVENTS); + if (ffd == -1) { + if (errno == ENOSPC) + errx(EXIT_FAILURE, _("%s: cannot add inotify watch " + "(limit of inotify watches was reached)."), + filename); + + err(EXIT_FAILURE, _("%s: cannot add inotify watch."), filename); + } + while (ffd >= 0) { len = read(fd, buf, sizeof(buf)); if (len < 0 && (errno == EINTR || errno == EAGAIN)) continue; if (len < 0) - err(EXIT_FAILURE, "%s: cannot read inotify events", filename); + err(EXIT_FAILURE, + _("%s: cannot read inotify events"), filename); for (e = 0; e < len; ) { struct inotify_event *ev = (struct inotify_event *) &buf[e]; -- 2.39.5