]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
retry waitpid on EINTR failure
authorDamien Miller <djm@mindrot.org>
Fri, 22 Jul 2016 04:06:36 +0000 (14:06 +1000)
committerDamien Miller <djm@mindrot.org>
Fri, 22 Jul 2016 04:07:08 +0000 (14:07 +1000)
patch from Jakub Jelen on bz#2581; ok dtucker@

auth-pam.c

index 1f13c181cae142f7dc3b741666fcc54e08c437fd..348fe370acd777e73ee95302efc910f6bf680713 100644 (file)
@@ -154,9 +154,12 @@ sshpam_sigchld_handler(int sig)
            <= 0) {
                /* PAM thread has not exitted, privsep slave must have */
                kill(cleanup_ctxt->pam_thread, SIGTERM);
-               if (waitpid(cleanup_ctxt->pam_thread, &sshpam_thread_status, 0)
-                   <= 0)
-                       return; /* could not wait */
+               while (waitpid(cleanup_ctxt->pam_thread,
+                   &sshpam_thread_status, 0) == -1) {
+                       if (errno == EINTR)
+                               continue;
+                       return;
+               }
        }
        if (WIFSIGNALED(sshpam_thread_status) &&
            WTERMSIG(sshpam_thread_status) == SIGTERM)
@@ -217,7 +220,11 @@ pthread_join(sp_pthread_t thread, void **value)
        if (sshpam_thread_status != -1)
                return (sshpam_thread_status);
        signal(SIGCHLD, sshpam_oldsig);
-       waitpid(thread, &status, 0);
+       while (waitpid(thread, &status, 0) == -1) {
+               if (errno == EINTR)
+                       continue;
+               fatal("%s: waitpid: %s", __func__, strerror(errno));
+       }
        return (status);
 }
 #endif