Fix Ctrl-C handling
authorDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 16 Oct 2008 08:58:22 +0000 (09:58 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 16 Oct 2008 08:58:22 +0000 (09:58 +0100)
mainloop.c

index 166faf6..07e9e2a 100644 (file)
@@ -119,10 +119,10 @@ int vpn_mainloop(struct openconnect_info *vpninfo)
 
                tv.tv_sec = timeout / 1000;
                tv.tv_usec = (timeout * 1000) % 1000000;
-               select(vpninfo->select_nfds, &rfds, &wfds, &efds, &tv);
-               if (FD_ISSET(vpninfo->ssl_fd, &efds)) {
-                       vpninfo->progress(vpninfo, PRG_ERR, "Server closed connection!\n");
+               if (select(vpninfo->select_nfds, &rfds, &wfds, &efds, &tv) >= 0
+                   && FD_ISSET(vpninfo->ssl_fd, &efds)) {
                        /* OpenSSL doesn't seem to cope properly with this... */
+                       vpninfo->progress(vpninfo, PRG_ERR, "Server closed connection!\n");
                        exit(1);
                }
        }