Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
627 B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <poll.h>
  4. #include <netdb.h>
  5. #include <unistd.h>
  6. #include <fcntl.h>
  7. #include <strings.h>
  8. #include <sys/types.h>
  9. #include <sys/socket.h>
  10. #include <sys/errno.h>
  11. #include <netinet/in.h>
  12. #include <sys/devpoll.h>
  13. main() {
  14. int fd=open("/dev/poll",O_RDWR);
  15. struct pollfd p[100];
  16. int i,r;
  17. dvpoll_t timeout;
  18. p[0].fd=0;
  19. p[0].events=POLLIN;
  20. write(fd,p,sizeof(struct pollfd));
  21. timeout.dp_timeout=100; /* milliseconds? */
  22. timeout.dp_nfds=1;
  23. timeout.dp_fds=p;
  24. r=ioctl(fd,DP_POLL,&timeout);
  25. for (i=0; i<r; ++i)
  26. printf("event %d on fd #%d\n",p[i].revents,p[i].fd);
  27. }