btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / tests / system / kernel / fifo_poll_test.cpp
blob4606e6581bfbadcfb338d716fdd297e62c712b92
1 #include <stdio.h>
2 #include <poll.h>
4 int main() {
5 FILE* f = popen("/bin/bash -c 'for i in 1 2 3; do { echo $i; sleep 1; }; done'", "r");
6 printf("f=%p\n", f);
7 int fd = fileno(f);
8 printf("fd=%d\n", fd);
10 struct pollfd pfd;
11 pfd.fd = fd;
12 pfd.events = POLLIN | POLLRDBAND;
14 char buffer[80];
16 while (1) {
17 int rv = poll(&pfd, 1, 500);
18 printf("rv=%d\n", rv);
19 if (rv == 0)
20 continue;
21 if (rv < 0)
22 break;
23 printf("events=%08x revents=%08x\n", pfd.events, pfd.revents);
24 if ((pfd.events & pfd.revents) == 0)
25 break;
27 fgets(buffer, 79, f);
28 printf("output: %s", buffer);
31 return 0;