diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2007-06-15 11:35:42 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2007-06-15 11:35:42 +0200 |
commit | d440e6dd7cb3db1f0c7b6723c098c5c31c530919 (patch) | |
tree | 11cd520f4262b62dcc9b218ac0055d6e1cbbfe75 | |
parent | 347124f77d9502a21652bff4868f7c53052a8fca (diff) |
inotail.c: Simplify EINTR handling in watch_files()
We don't need another loop, just continue the surrounding while() on
EINTR/EAGAIN
-rw-r--r-- | inotail.c | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -379,20 +379,15 @@ static int watch_files(struct file_struct *files, int n_files) ssize_t len; int ev_idx = 0; - /* Keep trying in the case of EINTR or EAGAIN*/ - for (;;) { - len = read(ifd, buf, (n_files * INOTIFY_BUFLEN)); - if (unlikely(len < 0)) { - /* Some form of signal, likely ^Z/fg's STOP and CONT interrupted the inotify read, retry */ - if (errno == EINTR || errno == EAGAIN) - continue; - else { - fprintf(stderr, "Error: Could not read inotify events (%s)\n", strerror(errno)); - exit(EXIT_FAILURE); - } + len = read(ifd, buf, (n_files * INOTIFY_BUFLEN)); + if (unlikely(len < 0)) { + /* Some form of signal, likely ^Z/fg's STOP and CONT interrupted the inotify read, retry */ + if (errno == EINTR || errno == EAGAIN) + continue; /* Keep trying */ + else { + fprintf(stderr, "Error: Could not read inotify events (%s)\n", strerror(errno)); + exit(EXIT_FAILURE); } - /* The read did succeed */ - break; } while (ev_idx < len) { |