about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/inputwin.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 2c42a628..2499f20a 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -71,6 +71,7 @@ static WINDOW *inp_win;
 static int pad_start = 0;
 
 static struct timeval p_rl_timeout;
+/* Timeout in ms. Shows how long select() may block. */
 static gint inp_timeout = 0;
 static gint no_input_count = 0;
 
@@ -115,14 +116,6 @@ create_input_window(void)
 #else
     ESCDELAY = 25;
 #endif
-    if (inp_timeout == 1000) {
-        p_rl_timeout.tv_sec = 1;
-        p_rl_timeout.tv_usec = 0;
-    } else {
-        p_rl_timeout.tv_sec = 0;
-        p_rl_timeout.tv_usec = inp_timeout * 1000;
-    }
-
     rl_readline_name = "profanity";
     rl_getc_function = _inp_rl_getc;
     rl_startup_hook = _inp_rl_startup_hook;
@@ -141,13 +134,17 @@ inp_readline(void)
 {
     free(inp_line);
     inp_line = NULL;
+    p_rl_timeout.tv_sec = inp_timeout / 1000;
+    p_rl_timeout.tv_usec = inp_timeout % 1000 * 1000;
     FD_ZERO(&fds);
     FD_SET(fileno(rl_instream), &fds);
     errno = 0;
     r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
     if (r < 0) {
-        char *err_msg = strerror(errno);
-        log_error("Readline failed: %s", err_msg);
+        if (errno != EINTR) {
+            char *err_msg = strerror(errno);
+            log_error("Readline failed: %s", err_msg);
+        }
         return NULL;
     }
 
@@ -169,14 +166,6 @@ inp_readline(void)
         prof_handle_idle();
     }
 
-    if (inp_timeout == 1000) {
-        p_rl_timeout.tv_sec = 1;
-        p_rl_timeout.tv_usec = 0;
-    } else {
-        p_rl_timeout.tv_sec = 0;
-        p_rl_timeout.tv_usec = inp_timeout * 1000;
-    }
-
     if (inp_line) {
         return strdup(inp_line);
     } else {
7functions.cc?h=main&id=f7ff8585b9f4ecd6871fb1e3980be9fe6a4486fd'>^
3ecd66fb ^
292ccba1 ^
871ea368 ^

292ccba1 ^








0cb988d0 ^
292ccba1 ^











1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77