Subject: How to do SIGIO on /dev/audio?
To: None <netbsd-users@netbsd.org>
From: Frederick Bruckman <fb@enteract.com>
List: netbsd-users
Date: 01/11/2000 03:04:07
What's the correct way to do SIGIO on the audio device?

I'm playing with ntpd-4.0.98m+, and finding that none of the audio
clocks will even configure. They all log an error after the following,
in libntp/iosignal.c:init_clock_sig()

	if (ioctl(rio->fd, TIOCSTTY, 0) == -1) ...

Evidently, the general plan for all clocks (except PPS), for all *BSD,
is

	ioctl(fd, TIOCSCTTY, 0)
	fcntl(fd, F_SETOWN, getpid())
	fcntl(fd, F_SETFL, FNDELAY|FASYNC)

which works fine for the modem and parse clocks (I guess: no errors,
but I haven't got one to dial out yet), but fails on the audio device.
The audio(4) man page says the audio device can do SIGIO, but it won't
take ioctl(fd, TIOCSCTTY, 0). That much is understandable, but then it
won't take fcntl(fd, F_SETOWN, ...), nor will it take ioctl(fd,
FIOSETOWN, ...) either. So how do you specify who gets the SIGIO?

Any insights appreciated.