From 2f44ef364bc320dfd73febc51f0c0da862db49b1 Mon Sep 17 00:00:00 2001 From: Matthias Dahl Date: Tue, 13 Mar 2018 15:35:16 +0100 Subject: [PATCH 3/3] Make xg_select() behave more like pselect() * src/xgselect.c (xg_select): If no file descriptors have data ready, pselect() clears the passed in fd sets whereas xg_select() does not which caused Bug#21337 for `wait_reading_process_output'. Clear the passed in sets if no fds are ready but leave them untouched if pselect() returns an error -- just like pselect() does itself. --- src/xgselect.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/xgselect.c b/src/xgselect.c index fedd3127ef..f68982143e 100644 --- a/src/xgselect.c +++ b/src/xgselect.c @@ -143,6 +143,14 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds, ++retval; } } + else if (nfds == 0) + { + // pselect() clears the file descriptor sets if no fd is ready (but + // not if an error occurred), so should we to be compatible. (Bug#21337) + if (rfds) FD_ZERO (rfds); + if (wfds) FD_ZERO (wfds); + if (efds) FD_ZERO (efds); + } /* If Gtk+ is in use eventually gtk_main_iteration will be called, unless retval is zero. */ -- 2.16.2