watcher.h (630B)
1 #ifndef WATCHER_H 2 #define WATCHER_H 3 4 #include <poll.h> 5 #include <stdbool.h> 6 7 #include "block.h" 8 #include "main.h" 9 10 enum watcher_fd_index { 11 SIGNAL_FD = BLOCK_COUNT, 12 WATCHER_FD_COUNT, 13 }; 14 15 typedef struct pollfd watcher_fd; 16 17 typedef struct { 18 watcher_fd fds[WATCHER_FD_COUNT]; 19 unsigned short active_blocks[BLOCK_COUNT]; 20 unsigned short active_block_count; 21 bool got_signal; 22 } watcher; 23 24 int watcher_init(watcher *const watcher, const block *const blocks, 25 const unsigned short block_count, const int signal_fd); 26 int watcher_poll(watcher *const watcher, const int timeout_ms); 27 28 #endif // WATCHER_H