]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Add some missing checks for EINTR after select(2).
authorSimon Tatham <anakin@pobox.com>
Fri, 6 Jan 2017 19:29:06 +0000 (19:29 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 6 Jan 2017 19:29:06 +0000 (19:29 +0000)
I noticed today that Unix Plink responds to SIGWINCH by accidentally
dying of EINTR having interrupted its main select loop, and when I
checked, there turn out to be a couple of other select loops with the
same bug.

unix/uxcons.c
unix/uxplink.c
unix/uxsftp.c

index 641c4b0f4aae914303c2fc44485d52c710cbb5c7..716f3fc533d653ccb0b6fa9751124d3df0a7d22f 100644 (file)
@@ -101,7 +101,9 @@ static int block_and_read(int fd, void *buf, size_t len)
         fd_set rfds;
         FD_ZERO(&rfds);
         FD_SET(fd, &rfds);
-        ret = select(fd+1, &rfds, NULL, NULL, NULL);
+        do {
+            ret = select(fd+1, &rfds, NULL, NULL, NULL);
+        } while (ret < 0 && errno == EINTR);
         assert(ret != 0);
         if (ret < 0)
             return ret;
index c59238a2c3f7af56ab0d8f4f77550d83bdc308b1..82693ba893ed98871afb5e37c52d662d717af113 100644 (file)
@@ -1122,6 +1122,9 @@ int main(int argc, char **argv)
             ret = select(maxfd, &rset, &wset, &xset, NULL);
         }
 
+        if (ret < 0 && errno == EINTR)
+            continue;
+
        if (ret < 0) {
            perror("select");
            exit(1);
index 6e39491010d7a04ef4d59ebd7366ac1e374929d9..a9fb9cb329cd65642aae2e12c2227f5607c54f26 100644 (file)
@@ -531,7 +531,9 @@ static int ssh_sftp_do_select(int include_stdin, int no_fds_ok)
                     now = GETTICKCOUNT();
             } while (ret < 0 && errno == EINTR);
         } else {
-            ret = select(maxfd, &rset, &wset, &xset, NULL);
+            do {
+                ret = select(maxfd, &rset, &wset, &xset, NULL);
+            } while (ret < 0 && errno == EINTR);
         }
     } while (ret == 0);