]> granicus.if.org Git - shadow/commitdiff
lib/spawn.c run_command: don't loop forever if waitpid() is returning ECHILD
authorThomas Abraham <tabraham@suse.com>
Thu, 25 Apr 2019 18:56:22 +0000 (14:56 -0400)
committerThomas Abraham <tabraham@suse.com>
Thu, 25 Apr 2019 18:56:22 +0000 (14:56 -0400)
If SIGCHILD is being ignored, waitpid() will forever error with ECHILD and
this loop with never end, so don't loop if it erros with ECHILD.

lib/spawn.c

index fc4ad95c7c429aeac246e0523073e9e82cf2a8df..79f5054e7eb3935145927e6e17ca1468482e0030 100644 (file)
@@ -68,8 +68,9 @@ int run_command (const char *cmd, const char *argv[],
 
        do {
                wpid = waitpid (pid, status, 0);
-       } while (   ((pid_t)-1 == wpid && errno == EINTR)
-                || ((pid_t)-1 != wpid && wpid != pid));
+       } while ( ((pid_t)-1 == wpid && errno != ECHILD)  
+                && (((pid_t)-1 == wpid && errno == EINTR)
+                || ((pid_t)-1 != wpid && wpid != pid)));
 
        if ((pid_t)-1 == wpid) {
                fprintf (stderr, "%s: waitpid (status: %d): %s\n",