- if(select(nfds+1, &rfds, NULL, NULL, NULL)>0)
+#ifdef _POSIX_SELECT
+ {
+ sigset_t oldmask;
+
+ mainloop_block_signals(&oldmask);
+
+ if(!mainloop_unhandled_signals())
+ ret=pselect(nfds+1, &rfds, NULL, NULL, NULL, &oldmask);
+
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
+ }
+#else
+ #warning "pselect() unavailable -- using dirty hacks"
+ {
+ struct timeval tv_={0, 0}, *tv=&tv_;
+
+ /* If there are timers, make sure we return from select with
+ * some delay, if the timer signal happens right before
+ * entering select(). Race conditions with other signals
+ * we'll just have to ignore without pselect().
+ */
+ if(!libmainloop_get_timeout(tv))
+ tv=NULL;
+
+ if(!mainloop_unhandled_signals())
+ ret=select(nfds+1, &rfds, NULL, NULL, tv);
+ }
+#endif
+ if(ret>0)