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.
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",