On Tue, Dec 09, 2008 at 09:57:25PM -0800, Philip Guenther wrote:

> On Tue, Dec 9, 2008 at 8:10 PM, Anirban Sinha <[EMAIL PROTECTED]> wrote:
> > There is yet another bug in Openntpd. This is direct copy-paste from
> > openntpd code (ntpd.c:main()):
> >
> > do {
> >                if ((pid = wait(NULL)) == -1 &&
> >                    errno != EINTR && errno != ECHILD)
> >                        fatal("wait");
> >        } while (pid != -1 || (pid == -1 && errno == EINTR));
> >
> > What this code intends to do is to reap all children and move on when
> > there are no more. Instead, it ends up blocking indefinitely even when
> > there are no children to reap!
> 
> How is it blocking indefinitely?  Is wait() not returning -1 with
> errno == ECHILD when there are no children to reap?  What led you to
> the conclusion that this code was blocking?  (What platform are you
> running this on?)
> 
> 
> > The way I fixed the bug is by doing this:
> > +       if (chld_pid && (pid = waitpid(chld_pid, &status, 0)) == -1 &&
> > +           errno != EINTR && errno != ECHILD)
> > +               fatal("wait");
> > +       if (pid !=-1)
> > +               log_info("child %d exited with return code %d", 
> > pid,WEXITSTATUS(status));
> 
> This code fails to retry the waitpid() if it returns with EINTR.
> 
> 
> Philip Guenther

Philip is right. The code is ok as is. Besides, in current ntpd has
multiple children, so you one child argument is lost as well.

I'd take a look at your other diff later.

        -Otto

Reply via email to