Thread View: comp.protocols.time.ntp
1 messages
1 total messages
Started by Cy Schubert
Tue, 28 Apr 2026 04:38
Re: ntpd does not start daemon control: got EOF
Author: Cy Schubert
Date: Tue, 28 Apr 2026 04:38
Date: Tue, 28 Apr 2026 04:38
183 lines
10556 bytes
10556 bytes
Ignore the typo in the patch. I can't type.
--
Cheers,
Cy Schubert <Cy.Schubert@cschubert.com>
FreeBSD UNIX: <cy@FreeBSD.org> Web: https://FreeBSD.org
NTP: <cy@nwtime.org> Web: https://nwtime.org
e**(i*pi)+1=0
In message <20260428042726.C382CE2@slippy.cwsent.com>, Cy Schubert writes:
> In message <d3493e70-2276-4c63-a4a4-7de5e6518cc0@ntp.org>, "Harlan Stenn"
> write
> s:
> > On 4/27/2026 4:33 PM, Cy Schubert wrote:
> > > In message <c125bd87-a762-4468-b214-5ead5147b82c@ntp.org>, "Harlan Stenn"
> > > write
> > > s:
> > >> On 4/27/2026 12:59 PM, Cy Schubert wrote:
> > >>> In message <CAMbSiYD=phHqGb=DjmYoZmYOjXWvv1r+TLex=ZjiyZHfaPYBAA@mail.gm
> ai
> > l.
> > >> c
> > >>> om>
> > >>> , Dave Hart writes:
> > >>>>
> > >>>> On Mon, Apr 27, 2026 at 14:11=E2=80=AFUTC Cy Schubert wrote:
> > >>>>
> > >>>>> The issue with ntpd is that it forks a subprocess, with a pipe betwee
> n
> > >>>>> both
> > >>>>> processes. The child process write "R\n" to the pipe. If the parent d
> oe
> > s
> > >>>>> not read two bytes it exits with an error. Just a guess here that mon
> it
> > >>>>> might have its fingers in the pipe.
> > >>>>>
> > >>>>
> > >>>> ntpd does have --nofork/-n to avoid forking to daemonize. I have not
> > >>>> tested, but intuitively it seems like a better solution for FreeBSD's
> rc
> > .d
> > >>>> script.
> > >>>>
> > >>>
> > >>> I suppose users of monit could use that. rcng uses the .pid file to man
> ag
> > e
> > >>> services. I don't see any benefit of changing the FreeBSD rc file to
> > >>> support an esoteric process monitoring application. Applications should
> > >>> conform to and work within the O/S, not the other way around. Though no
> t
> > >>> posix pidfiles are a common UNIX-like management tool.
> > >>
> > >> We believe we provide a robust mechanism for ntpd startup. If there is
> > >> missing functionality here, please open a bug report.
> > >>
> > >> There are a staggering number of systems out there that use a myriad of
> > >> different startup schemes. Any given system can undergo spontaneous
> > >> changes in its startup framework.
> > >>
> > >> It seems unreasonable to me to expect *any* application project
> > >> (including NTP) to conform to an OS.
> > >>
> > >> But it *is* perfectly reasonable to expect an application project to
> > >> offer command-line and configuration options that are sufficiently
> > >> robust to allow an arbitrary OS to reliably start/stop the application.
> > >>
> > >> Are we agreed on this?
> > >
> > > In this regard ntp (and sendmail) are working correctly. The issue only
> > > occurs when run under monit. Monit might be inserting itself between the
> > > parent and the child in order to cause the parent not to read "R\n" on th
> e
> > > pipe.
> >
> > Cool, thanks!
> >
> > > I have confirmed, in a jail on a 16-CURRENT system, that the problem only
> > > occurs under monit. This is why I suggested the O/P open a bugzilla bug f
> or
> > > the problem. It's one of the following:
> > >
> > > - a monit bug, or
> > > - a bug uncovered by monit in the FreeBSD kernel or libc.
> > >
> > > What ntpd is doing by opening a pipe so the child can notify the parent i
> t
> > > can terminate itself looks reasonable.
> > >
> > >
> > >>
> > >> --
> > >> Harlan Stenn <stenn@ntp.org>
> > >> NTP Project Lead. The NTP Project is part of:
> > >> https://www.nwtime.org/ - be a member!
> > >
> > >
> >
> > --
> > Harlan Stenn <stenn@ntp.org>
> > NTP Project Lead. The NTP Project is part of:
> > https://www.nwtime.org/ - be a member!
>
> I'll try to nail this down this week. Just to rule out whether the child is
> terminating the following DTrace probes will, hopefully, point me in a
> direction to better understand this.
>
> diff --git a/contrib/ntp/ntpd/ntpd.c b/contrib/ntp/ntpd/ntpd.c
> index b64caae06da1..6095e2144925 100644
> --- a/contrib/ntp/ntpd/ntpd.c
> +++ b/contrib/ntp/ntpd/ntpd.c
> @@ -134,6 +134,9 @@
> # include <sys/resource.h>
> # include <seccomp.h>
> #endif /* LIBSECCOMP and KERN_SECCOMP */
> +#if defined(__FreeBSD__)
> +#include <sys.sdt.h>
> +#endif
>
> #if defined(__FreeBSD__) && __FreeBSD_version < 1400037 &&
> defined(HAVE_SYS_PROCCTL_H)
> # include <sys/procctl.h>
> @@ -1444,7 +1447,15 @@ int scmp_sc[] = {
> if (daemon_pipe[1] != -1 && 0 == wait_sync) {
> if (2 != write(daemon_pipe[1], "R\n", 2)) {
> msyslog(LOG_ERR, "daemon failed to notify parent ntpd a
> fter init");
> +#if defined(__FreeBSD__)
> + DTRACE_PROBE(ntpd, child_notify_parent_fail)
> +#endif
> }
> +#if defined(__FreeBSD__)
> + else {
> + DTRACE_PROBE(ntpd, child_notify_success)
> + }
> +#endif
> close(daemon_pipe[1]);
> daemon_pipe[1] = -1;
> }
> @@ -1694,16 +1705,25 @@ wait_child_sync_if(
> if (rc == 0) {
> /* DPRINTF is useless here as -d/-D disable forking */
> fprintf(stderr, "daemon control: got EOF\n");
> +#if defined(__FreeBSD__)
> + DTRACE_PROBE(ntpd, parent_got_eof)
> +#endif
> return -1; /* unexpected EOF, check daemon */
> } else if (rc == 1) {
> if ( ('S' == ch && wait_sync > 0)
> || ('R' == ch && 0 == wait_sync)) {
> +#if defined(__FreeBSD__)
> + DTRACE_PROBE(ntpd, parent_got_char)
> +#endif
> return 0;
> }
> } else {
> mfprintf(stderr, "%s: daemon control: read 1 char faile
> d: %m\n",
> progname);
> msyslog(LOG_ERR, "daemon control: read 1 char failed: %
> m");
> +#if defined(__FreeBSD__)
> + DTRACE_PROBE(ntpd, parent_pipe_read_fail)
> +#endif
> return EX_IOERR;
> }
> } while (wait_rem > 0);
>
>
> --
> Cheers,
> Cy Schubert <Cy.Schubert@cschubert.com>
> FreeBSD UNIX: <cy@FreeBSD.org> Web: https://FreeBSD.org
> NTP: <cy@nwtime.org> Web: https://nwtime.org
>
> e**(i*pi)+1=0
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads