[comp.protocols.time.ntp] XNTPD on an Apollo?

hanche@imf.unit.no (Harald Hanche-Olsen) (12/29/90)

I have been trying to port xntpd to the Apollo, and have run into
trouble.  What xntpd does is open a bunch of UDP sockets, and set them
up to send an IO signal whenever input arrives by saying

  fcntl(fd, F_SETOWN, getpid())

Then the program happily goes to sleep with a sigpause(), knowing that
it will be woken up when there is work to do.  However, tha man page
for fcntl says

NOTES
     Presently, Domain/OS BSD does not implement the following cmds:

     F_GETOWN   [...]

     F_SETOWN   Set the process or process group to receive SIGIO and SIGURG
                signals; process groups are specified by supplying arg as
                negative; otherwise, arg is interpreted as a process ID.

so the daemon just sleeps forever in the sigpause() call.  I have
verified that, if I try to contact the xntpd via ntpq, it times out -
but if I send xntpd an IO signal (kill -IO ...) before ntpq times out,
I do get the expected response.

Has anyone managed to get around this and port xntpd to the Apollo?
Or if not, any suggestions?  I'd rather not have to restructure the
whole program to make this work...  I tried substituting the call
fcntl(fd, F_SETFL, FASYNC) for the above call, but to no avail.  From
reading the man page, it is not clear to me whether or not it ought
to.

- Harald Hanche-Olsen <hanche@imf.unit.no>
  Division of Mathematical Sciences
  The Norwegian Institute of Technology
  N-7034 Trondheim, NORWAY

rees@pisa.ifs.umich.edu (Jim Rees) (01/01/91)

In article <HANCHE.90Dec29001324@hufsa.imf.unit.no>, hanche@imf.unit.no (Harald Hanche-Olsen) writes:

  I have been trying to port xntpd to the Apollo, and have run into
  trouble.  What xntpd does is open a bunch of UDP sockets, and set them
  up to send an IO signal whenever input arrives by saying
  
    fcntl(fd, F_SETOWN, getpid())

I'm not sure why the manual says this is not implemented.  It is.

In Berkeley Unix, only sockets can be owned by a single process.  If you try
to set the owner of a tty to a process, it ends up being owned by the group
that process is in.

In Domain/OS, you can't set either sockets or ttys to be owned by an
individual process.  They are always owned by a process group.

The problem with xntpd is that when you start it up, it doesn't divorce
itself from its process group.  So when it does the SETOWN, the socket ends
up being owned by the group of the process that started xntpd, not the group
that xntpd is currently in.

You can fix this by adding a setpgrp().  ntpdate has the same problem.

You can get a set of patches for xntpd from dabo.ifs.umich.edu.