Date: Wed, 11 Oct 1995 10:32:46 +1000 From: Bruce Evans <bde@zeta.org.au> To: bde@zeta.org.au, pst@cisco.com, stu@cisco.com Cc: hackers@freebsd.org Subject: Re: FleeBSD and XNTPD Message-ID: <199510110032.KAA12603@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>>It can't be done that way. Under FreeBSD, the following all seems to be >>necessary: >> >> setsid(); >> ioctl(fd, TIOCSCTTY); >> fcntl(fd, F_SETOWN, getpid()); >> fl = fcntl(fd, F_GETFL); >> fcntl(fd, F_SETFL, fl | O_ASYNC); >> >>Plus error checking and setting up the signal handler of course. >> >Well, tried all this and alas still no joy... The setsid() call fails - >returning -1 - a browse through ntpd.c shows that setsid() has already been >called when the original controlling terminal is detached. Yes, it calls daemon(). This took more than a browse to see because of the ifdef forest. >Next the TIOCSCTTY fails - again with inappropriate IOCTL for device - I >checked the file handle that is returned by open in refclock_open and by >jove its the same one being used here - so it should work. I put a TIOCSCTTY in refclock_open() for /dev/cuaa0 and it worked. The errno ENOTTY can't be returned for TIOCSCTTY on normal ttys. What device are you using exactly? I tested with `server 127/127.3.0' in /etc/ntp.conf and /dev/cuaa0 linked to /dev/pst0 to get the pst refclock (Hi pst :-). >To further shroud this thing in mystery, I added a call to ioctl(TIOCGPGRP) >to get the controlling process for the fd and that call also fails with >inappro. ioctl. This is normal when there is no controlling tty. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510110032.KAA12603>