screen-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[screen-devel] [PATCH 2/4] Convert select() to poll() in screen.c


From: Amadeusz Sławiński
Subject: [screen-devel] [PATCH 2/4] Convert select() to poll() in screen.c
Date: Sun, 3 Nov 2019 00:31:58 +0100

select() limits number of file descriptors that can be used by screen.
Migrate to poll() to avoid this limitation.

Bug: 55697

Signed-off-by: Amadeusz Sławiński <address@hidden>
---
 src/screen.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/screen.c b/src/screen.c
index bf2adfdb..e35e7fbd 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -34,6 +34,7 @@
 
 #include <ctype.h>
 #include <fcntl.h>
+#include <poll.h>
 #include <pwd.h>
 #include <signal.h>
 #include <stdint.h>
@@ -1036,14 +1037,14 @@ int main(int argc, char **argv)
 
        if (mru_window == NULL) {
                if (MakeWindow(&nwin) == -1) {
-                       fd_set rfd;
-                       FD_ZERO(&rfd);
-                       struct timeval tv = { MsgWait / 1000, 1000 * (MsgWait % 
1000) };
-                       FD_SET(0, &rfd);
+                       struct pollfd pfd[1];
+
+                       pfd[0].fd = 0;
+                       pfd[0].events = POLLIN;
 
                        Msg(0, "Sorry, could not find a PTY or TTY.");
                        /* allow user to exit early by pressing any key. */
-                       select(1, &rfd, NULL, NULL, &tv);
+                       poll(pfd, ARRAY_SIZE(pfd), MsgWait);
                        Finit(0);
                        /* NOTREACHED */
                }
-- 
2.23.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]