} else
rc = fwrite(p, 1, len, out) != len;
- if (rc != 0) {
- if (errno != EPIPE)
- err(EXIT_FAILURE, _("write failed"));
- exit(EXIT_SUCCESS);
- }
+ if (rc != 0 && errno != EPIPE)
+ err(EXIT_FAILURE, _("write failed"));
}
}
/*
* Print file in small chunks to save memory
*/
- while (size) {
+ while (size && !ferror(stdout)) {
size_t sz = size > ctl->pagesize ? ctl->pagesize : size;
char *x = ctl->mmap_buff;
return;
}
- while (get_next_syslog_record(ctl, &rec) == 0)
+ while (get_next_syslog_record(ctl, &rec) == 0 && !ferror(stdout))
print_record(ctl, &rec);
}
*/
sz = ctl->kmsg_first_read;
- while (sz > 0) {
+ while (sz > 0 && !ferror(stdout)) {
*(ctl->kmsg_buf + sz) = '\0'; /* for debug messages */
if (parse_kmsg_record(ctl, &rec,
if (ctl->method != DMESG_METHOD_KMSG || !ctl->filename)
return -1;
- while (sz > 0) {
+ while (sz > 0 && !ferror(stdout)) {
len = strnlen(ctl->mmap_buff, sz);
if (len > sizeof(str))
errx(EXIT_FAILURE, _("record too large"));