|
|
1.1 root 1: #include <stropts.h>
2: #include <fcntl.h>
3: #include <stdio.h>
4: #include <poll.h>
5:
6: int main (argc, argv)
7: int argc;
8: char * argv [];
9: {
10: int fd;
11: char buf [20];
12: int cnt;
13: struct pollfd fds [1];
14:
15: if ((fd = open ("/dev/echo", O_RDWR)) == -1) {
16:
17: perror ("Couldn't open /dev/echo");
18: return -1;
19: }
20:
21: fprintf (stderr, "Returned %d\n", fd);
22:
23: fprintf (stderr, "PUSH ioctl () says %d\n", ioctl (fd, I_PUSH, "dump"));
24: fprintf (stderr, "SRDOPT ioctl () says %d\n", ioctl (fd, I_SRDOPT, RMSGN));
25:
26: write (fd, "Foo!", 5);
27:
28: fds->fd = fd;
29: fds->events = POLLIN;
30: if (poll (fds, 1, 0) == -1) {
31: fprintf (stderr, "Got error from poll ()\n");
32: return -1;
33: }
34: fprintf (stderr, "Got event 0x%x\n", fds->revents);
35:
36: cnt = read (fd, buf, sizeof (buf));
37: buf [cnt] = 0;
38:
39: fprintf (stderr, "Read %d bytes, result = %s\n", cnt, buf);
40:
41: close (fd);
42:
43: return 0;
44: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.