diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2007-05-20 21:57:03 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2007-05-20 21:57:03 +0200 |
commit | 97fc6ccc502804ca5f6bd4e069ed4b8a12cc1bac (patch) | |
tree | a8d7f8a7c97d42573777b09d510fe5a9e06f35ac /inotail.c | |
parent | 07f00e65f41f6b450798628ec194b7f95cea0ade (diff) |
inotail.c: Some more error checking in tail_pipe()
Taken from a patch by Folkert van Heusden
Diffstat (limited to 'inotail.c')
-rw-r--r-- | inotail.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -221,8 +221,13 @@ static ssize_t tail_pipe(struct file_struct *f) write_header(f->name); /* We will just tail everything here */ - while ((rc = read(f->fd, buf, BUFFER_SIZE)) > 0) - write(STDOUT_FILENO, buf, (size_t) rc); + while ((rc = read(f->fd, buf, BUFFER_SIZE)) > 0) { + if (write(STDOUT_FILENO, buf, (size_t) rc)) { + /* e.g. when writing to a pipe which gets closed */ + fprintf(stderr, "Error: Could not write to stdout: %s\n", strerror(errno)); + return -1; + } + } return rc; } |