diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-08-30 22:56:47 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-08-30 22:56:47 +0100 |
| commit | 8b02bb749dece7690f4919372d19cd40907b91b1 (patch) | |
| tree | 98e636beca5e83f909d3872586f383e95095851b /src/buffer_utils.cc | |
| parent | d0a29511d28f1481622ac9bb3a6ebfa9f8988c2b (diff) | |
Add a fd_readable(int fd) helper function
Use it instead of direct calls to select scatered around the code
base.
Diffstat (limited to 'src/buffer_utils.cc')
| -rw-r--r-- | src/buffer_utils.cc | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc index 8e61c28e..09a65952 100644 --- a/src/buffer_utils.cc +++ b/src/buffer_utils.cc @@ -4,9 +4,6 @@ #include "event_manager.hh" #include "file.hh" -#include <unistd.h> -#include <sys/select.h> - #if defined(__APPLE__) #define st_mtim st_mtimespec #endif @@ -120,8 +117,6 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll) size_t loops = 16; char data[buffer_size]; const int fifo = watcher.fd(); - timeval tv{ 0, 0 }; - fd_set rfds; ssize_t count = 0; do { @@ -142,12 +137,8 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll) if (data[count-1] == '\n') buffer->insert(buffer->end_coord(), "\n"); } - - FD_ZERO(&rfds); - FD_SET(fifo, &rfds); } - while (--loops and count > 0 and - select(fifo+1, &rfds, nullptr, nullptr, &tv) == 1); + while (--loops and count > 0 and fd_readable(fifo)); buffer->run_hook_in_own_context("BufReadFifo", buffer->name()); |
