File: config.poll-dev.c

package info (click to toggle)
gnustep-base 1.24.7-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 24,176 kB
  • ctags: 5,535
  • sloc: objc: 966,973; ansic: 31,274; makefile: 317; cpp: 110; sh: 102; xml: 28
file content (24 lines) | stat: -rw-r--r-- 504 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Mac OS X has a native poll implementation since Mac OS X 10.4, but
 * this implementation is broken in (at least) OS X 10.4 and 10.5 in
 * that it does not support devices.
 */

#include <stdio.h>
#include <fcntl.h>
#include <poll.h>

int
main()
{
  int fd, n;
  struct pollfd pollfds[1];

  fd = open("/dev/null", O_RDONLY | O_NONBLOCK, 0);

  pollfds[0].fd = fd;
  pollfds[0].events = POLLIN;
  n = poll(pollfds, 1, 0);
  close(fd);

  return (n == 1 && !(pollfds[0].revents & POLLNVAL)) ? 0 : 1;
}