Subject: Re: async I/O
To: Jan-Hinrich Fessel <>
From: Tom I Helbekkmo <tih@Hamartun.Priv.NO>
List: current-users
Date: 09/04/1996 15:33:08
On Wed, 4 Sep 1996, Jan-Hinrich Fessel wrote:

> In fact, this wasn't my problem at all, for after changing he
> relevant files, i get the familiar message:

> Sep 4 08:58:46 xntpd[20057]: ioctl(TIOCSCTTY, 0)
> fails for clock I/O: Operation not permitted

> That is produced, when i start xntpd -d.  Now, if I start it without
> debugging, it seems to work:

That's part of the workaround in xntpd for the missing implementation
of a "real" F_SETOWN.  The code goes like this:

#if defined(TIOCSCTTY) && defined(USE_FSETOWNCTTY)
	 * there are, however, always exceptions to the rules
	 * one is, that OSF accepts SETOWN on TTY fd's only, iff they are
	 * CTTYs. SunOS and HPUX do not semm to have this restriction.
	 * another question is: how can you do multiple SIGIO from several
	 * ttys (as they all should be CTTYs), wondering...
	 * kd 95-07-16
	if (ioctl(rio->fd, TIOCSCTTY, 0) == -1) {
		syslog(LOG_ERR, "ioctl(TIOCSCTTY, 0) fails for clock I/O: %m");
		return 1;

        if (fcntl(rio->fd, F_SETOWN, getpid()) == -1) {
                syslog(LOG_ERR, "fcntl(F_SETOWN) fails for clock I/O: %m");
                return 1;

The TIOCSCTTY is needed because it's the only way xntpd will be
allowed to do the F_SETOWN (which it must do), but a side effect is
that it cannot do this unless it's in the background.  Thus, until
either F_SETOWN is actually implemented under NetBSD, or some more
complicated workaround is done for xntpd, it's impossible to run it
with the '-d' flag.

Tom Ivar Helbekkmo