1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Merge remote-tracking branch 'pasis/ui-ignore-EINTR'

This commit is contained in:
James Booth 2015-07-01 20:55:22 +01:00
commit 446f5f0aa1

View File

@ -71,6 +71,7 @@ static WINDOW *inp_win;
static int pad_start = 0; static int pad_start = 0;
static struct timeval p_rl_timeout; static struct timeval p_rl_timeout;
/* Timeout in ms. Shows how long select() may block. */
static gint inp_timeout = 0; static gint inp_timeout = 0;
static gint no_input_count = 0; static gint no_input_count = 0;
@ -115,14 +116,6 @@ create_input_window(void)
#else #else
ESCDELAY = 25; ESCDELAY = 25;
#endif #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_readline_name = "profanity";
rl_getc_function = _inp_rl_getc; rl_getc_function = _inp_rl_getc;
rl_startup_hook = _inp_rl_startup_hook; rl_startup_hook = _inp_rl_startup_hook;
@ -141,13 +134,17 @@ inp_readline(void)
{ {
free(inp_line); free(inp_line);
inp_line = NULL; inp_line = NULL;
p_rl_timeout.tv_sec = inp_timeout / 1000;
p_rl_timeout.tv_usec = inp_timeout % 1000 * 1000;
FD_ZERO(&fds); FD_ZERO(&fds);
FD_SET(fileno(rl_instream), &fds); FD_SET(fileno(rl_instream), &fds);
errno = 0; errno = 0;
r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout); r = select(FD_SETSIZE, &fds, NULL, NULL, &p_rl_timeout);
if (r < 0) { if (r < 0) {
char *err_msg = strerror(errno); if (errno != EINTR) {
log_error("Readline failed: %s", err_msg); char *err_msg = strerror(errno);
log_error("Readline failed: %s", err_msg);
}
return NULL; return NULL;
} }
@ -169,14 +166,6 @@ inp_readline(void)
prof_handle_idle(); 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) { if (inp_line) {
return strdup(inp_line); return strdup(inp_line);
} else { } else {