X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=x5%2Fkhatus.c;h=ce7db950a1355212c614d9554f1975f1e5fb2e24;hb=eb6dbe7a1ae8ed5ff871a4a98a4e95793155d5e0;hp=43a828bcc719cbf46ca9a67adf15658885461f11;hpb=17e4ecd509e1ad64c1b083924271603204046b01;p=khatus.git diff --git a/x5/khatus.c b/x5/khatus.c index 43a828b..ce7db95 100644 --- a/x5/khatus.c +++ b/x5/khatus.c @@ -397,12 +397,13 @@ fifo_read_one(Fifo *f, struct timespec t, char *buf) } void -fifo_read_all(Config *cfg, struct timespec t, char *buf) +fifo_read_all(Config *cfg, struct timespec *ti, char *buf) { fd_set fds; int maxfd = -1; int ready = 0; struct stat st; + struct timespec t; FD_ZERO(&fds); for (Fifo *f = cfg->fifos; f; f = f->next) { @@ -435,12 +436,10 @@ fifo_read_all(Config *cfg, struct timespec t, char *buf) FD_SET(f->fd, &fds); } debug("selecting...\n"); - ready = select(maxfd + 1, &fds, NULL, NULL, NULL); + ready = pselect(maxfd + 1, &fds, NULL, NULL, ti, NULL); debug("ready: %d\n", ready); - assert(ready != 0); - if (ready < 0) - /* TODO: Do we really want to fail here? */ - fatal("%s", strerror(errno)); + assert(ready >= 0); + clock_gettime(CLOCK_MONOTONIC, &t); while (ready) { for (Fifo *f = cfg->fifos; f; f = f->next) { if (FD_ISSET(f->fd, &fds)) { @@ -555,11 +554,7 @@ main(int argc, char *argv[]) /* TODO: Handle signals */ for (;;) { clock_gettime(CLOCK_MONOTONIC, &t0); // FIXME: check errors - /* TODO: Set timeout on fifo_read_all based on diff of last time of - * fifo_read_all and desired time of next TTL check? - */ - /* TODO: How long to wait on IO? Max TTL? */ - fifo_read_all(cfg, t0, buf); + fifo_read_all(cfg, &ti, buf); if (cfg->output_to_x_root_window) { if (XStoreName(display, DefaultRootWindow(display), buf) < 0) fatal("XStoreName failed.\n");