From dc0c278fb1e831bd55cca152fcb455e0c901867e Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 20 Jun 2017 15:09:43 -0700 Subject: [PATCH] Block SIGWINCH during connect(). (closes #3941) FreeBSD's connect() does not respect SA_RESTART, so a SIGWINCH will end up interrupting the connect. If this code is needed in other places, it should be moved into signal.c. For this one place, inlining the sigprocmask() seemed okay. --- mutt_socket.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mutt_socket.c b/mutt_socket.c index a2c489f6..08f21533 100644 --- a/mutt_socket.c +++ b/mutt_socket.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #ifdef HAVE_SYS_TIME_H @@ -344,6 +345,7 @@ static int socket_connect (int fd, struct sockaddr* sa) { int sa_size; int save_errno; + sigset_t set; if (sa->sa_family == AF_INET) sa_size = sizeof (struct sockaddr_in); @@ -356,12 +358,18 @@ static int socket_connect (int fd, struct sockaddr* sa) dprint (1, (debugfile, "Unknown address family!\n")); return -1; } - + if (ConnectTimeout > 0) alarm (ConnectTimeout); mutt_allow_interrupt (1); + /* FreeBSD's connect() does not respect SA_RESTART, meaning + * a SIGWINCH will cause the connect to fail. */ + sigemptyset (&set); + sigaddset (&set, SIGWINCH); + sigprocmask (SIG_BLOCK, &set, NULL); + save_errno = 0; if (connect (fd, sa, sa_size) < 0) @@ -374,6 +382,7 @@ static int socket_connect (int fd, struct sockaddr* sa) if (ConnectTimeout > 0) alarm (0); mutt_allow_interrupt (0); + sigprocmask (SIG_UNBLOCK, &set, NULL); return save_errno; } -- 2.40.0