int priority;
char * tag;
struct epoll_event ev = { .events = EPOLLOUT, .data.fd = reader->file.fd };
- int epoll_fd;
+ int epoll_fd = -1;
int from = reader->current;
- int is_file = 0;
int plaintext = 0;
- epoll_fd = epoll_create1(0);
- r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, reader->file.fd, &ev);
- if (r == -1 && errno == EPERM)
- is_file = 1;
+ if (!reader->file.path) { // pipe, not file
+ epoll_fd = epoll_create1(0);
+ r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, reader->file.fd, &ev);
+ if (r < 0) {
+ close(epoll_fd);
+ return 0;
+ }
+ }
- plaintext = is_file && (reader->buf_id == LOG_ID_KMSG);
+ plaintext = reader->file.path && (reader->buf_id == LOG_ID_KMSG);
if (reader->partial_log_size) {
- if (!is_file && epoll_wait(epoll_fd, &ev, 1, 0) < 1)
+ if (!reader->file.path && epoll_wait(epoll_fd, &ev, 1, 0) < 1)
goto cleanup;
do {
if (!log_should_print_line(reader->file.format, tag, priority))
continue;
- if (!is_file) {
+ if (!reader->file.path) {
if (epoll_wait(epoll_fd, &ev, 1, 0) < 1)
goto cleanup;
}
}
- if (is_file && !plaintext)
+ if (reader->file.path && !plaintext)
ret = write_blob_to_file(reader, &g_file_buffer);
if (reader->dumpcount)
ret = -1;
cleanup:
- close(epoll_fd);
+ if (!reader->file.path)
+ close(epoll_fd);
reader->current = from;
return ret;
}