misc/89775: kevent hangs on second wait for /dev/dsp

Yuri yuri at tsoft.com
Wed Nov 30 20:20:06 GMT 2005

>Number:         89775
>Category:       misc
>Synopsis:       kevent hangs on second wait for /dev/dsp
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 30 20:20:03 GMT 2005
>Originator:     Yuri
>Release:        5.4 stable
FreeBSD xxx.xxx.xxx 5.4-RELEASE-p3 FreeBSD 5.4-RELEASE-p3 #0: Thu Jul  7 22:03:34 PDT 2005     xxx at xxx.xxx.xxx:/usr/src/sys/i386/compile/GENERIC  i386
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>

compile and run the following 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>
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
  res = kevent(kq,
     &kev, 1,
     &result_events[0], 256,
  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
  res = kevent(kq,
     NULL/*&kev*/, 0,
     &result_events[0], 256,
  printf("<kevent2 returned %i\n", res);
  return (0);


More information about the freebsd-bugs mailing list