]> 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>
Mon, 6 May 2019 18:26:14 +0000 (14:26 -0400)
committerThomas Abraham <tabraham@suse.com>
Mon, 6 May 2019 18:26:14 +0000 (14:26 -0400)
If SIGCHILD is being ignored, waitpid() will forever error with ECHILD and
this loop with never end, so don't loop if it errors with ECHILD.

lib/spawn.c

index fc4ad95c7c429aeac246e0523073e9e82cf2a8df..d0b5fb26e2594a2ee13c1e1948361e5d2c90b4f0 100644 (file)
@@ -68,6 +68,8 @@ int run_command (const char *cmd, const char *argv[],
 
        do {
                wpid = waitpid (pid, status, 0);
+               if ((pid_t)-1 == wpid && errno == ECHILD)
+                       break;
        } while (   ((pid_t)-1 == wpid && errno == EINTR)
                 || ((pid_t)-1 != wpid && wpid != pid));