If kernel queue has sound device /dev/dsp in it kevent only being triggered once. Second call to it hangs although data is obviously continuously available from soundcard. relevant dmesg messages describing the card are: pcm0: <Creative EMU10K1> port 0xdc00-0xdc1f irq 17 at device 6.0 on pci0 pcm0: <TriTech TR28602 AC97 Codec> Fix: N/A How-To-Repeat: compile and run the following code: ----code------ #include <unistd.h> #include <sys/types.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/soundcard.h> #include <sys/types.h> #include <sys/event.h> int main(int argc, char *argv[]) { int res, kq; int dsp; kq = kqueue(); printf("kqueue returned %i\n", kq); char buf[1024]; dsp = open("/dev/dsp", O_RDONLY); struct kevent kev; EV_SET(&kev, dsp, EVFILT_READ, EV_ADD, 0/*fflags*/, 0/*data*/, NULL); struct kevent result_events[256]; // 1 printf(">kevent1\n"); res = kevent(kq, &kev, 1, &result_events[0], 256, NULL ); printf("<kevent1 returned %i\n", res); printf(">read returned %i\n", res); res = read(dsp, buf, sizeof(buf)); printf("<read returned %i\n", res); // 2 printf(">kevent2\n"); res = kevent(kq, NULL/*&kev*/, 0, &result_events[0], 256, NULL ); printf("<kevent2 returned %i\n", res); // close(dsp); return (0); }
Moreover, if right after open I make FD async with these 2 lines: int on = 1; ioctl(dsp, FIONBIO, &on); the first 'read' call fails with 'Resource temporarily unavailable' error (right after kevent returns that data is available). Yuri