URI: 
       pselect: set a timeout of 1 second - teed - A multiplex relay tee(1) daemon.
  HTML git clone git://bitreich.org/teed git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/teed
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 8d1db0f43e921b998a06dd61d1442220db29ee89
   DIR parent 18db7808b4a41155537b83db1294720403990b4c
  HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Mon, 14 Aug 2023 14:22:16 +0200
       
       pselect: set a timeout of 1 second
       
       This is for sockets that are closed. These are signalled by FD_ISSET and a
       read() that returns 0.  This way it can handle them directly when it occurs vs
       on the next read of a socket.
       
       Signed-off-by: Christoph Lohmann <20h@r-36.net>
       
       Diffstat:
         M teed.c                              |       5 ++++-
       
       1 file changed, 4 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/teed.c b/teed.c
       @@ -161,6 +161,7 @@ main(int argc, char *argv[])
                llist *wfds, *rfds, *lfds, *e, *qe;
                socklen_t saddrlen, cltlen;
                fd_set fdset;
       +        struct timespec timeout;
        
                initsignals();
        
       @@ -210,6 +211,8 @@ main(int argc, char *argv[])
                        lfds = llist_put(lfds, &lfd, sizeof(lfd));
                }
        
       +        timeout.tv_sec = 1;
       +        timeout.tv_nsec = 0;
                for (;;) {
                        maxsfd = 0;
                        FD_ZERO(&fdset);
       @@ -224,7 +227,7 @@ main(int argc, char *argv[])
                                        maxsfd = *(int *)e->data;
                        }
        
       -                if (pselect(maxsfd+1, &fdset, NULL, NULL, NULL, NULL) < 0) {
       +                if (pselect(maxsfd+1, &fdset, NULL, NULL, &timeout, NULL) < 0) {
                                if (errno == EINTR)
                                        continue;
                                perror("pselect");