#include #include #include #include main() { int kq,fd; struct kevent cl,evl; int data,udata; int res; kq = kqueue(); fd=open("/dev/acpi",O_RDONLY); EV_SET(&cl, fd, EVFILT_READ, EV_ADD|EV_ENABLE|EV_CLEAR, 0xffffffff,&data,&udata); kevent(kq,&cl,1,NULL,0,NULL); for(;;){ res = kevent(kq,NULL,0,&cl,1,NULL); printf("%d\n",res); printf("%x\n",cl.fflags); } }