dopoll(fd, POLLIN|POLLOUT, "POLLIN|POLLOUT", timeout);
dopoll(fd, POLLIN, "POLLIN", timeout);
dopoll(fd, POLLOUT, "POLLOUT", timeout);
+ dopoll(fd, 0, "(none)", timeout);
doselect(fd, fd, timeout);
doselect(fd, -1, timeout);
doselect(-1, fd, timeout);
+ doselect(-1, -1, timeout);
if (write(fd, "test", 4) != 4) {
printf("write error: %s\n", strerror(errno));
dopoll(fd, POLLIN|POLLOUT, "POLLIN|POLLOUT", timeout);
dopoll(fd, POLLIN, "POLLIN", timeout);
dopoll(fd, POLLOUT, "POLLOUT", timeout);
+ dopoll(fd, 0, "(none)", timeout);
doselect(fd, fd, timeout);
doselect(fd, -1, timeout);
doselect(-1, fd, timeout);
+ doselect(-1, -1, timeout);
if ((nread = read(fd, buf, sizeof(buf))) <= 0) {
printf("read error: %s\n", (nread == 0) ? "EOF" : strerror(errno));
/*
* Test all combinations of select and poll.
*/
- for (pass = 0; pass < 12; pass++) {
+ for (pass = 0; pass < 16; pass++) {
/*
* We run each test twice, once with a fresh fifo,
* and once with a reused one.
break;
case 6:
case 7:
- doselect(fd, fd, timeout);
+ dopoll(fd, 0, "(none)", timeout);
break;
case 8:
case 9:
- doselect(fd, -1, timeout);
+ doselect(fd, fd, timeout);
break;
case 10:
case 11:
+ doselect(fd, -1, timeout);
+ break;
+ case 12:
+ case 13:
doselect(-1, fd, timeout);
break;
+ case 14:
+ case 15:
+ doselect(-1, -1, timeout);
+ break;
}
wait(&status);
if ((nread = read(fd, buf, sizeof(buf))) < 0) {
FD_SET(wfd, wfds);
}
- printf("\tselect%s%s\n", rfds ? " read" : "",
- wfds ? " write" : "");
+ printf("\tselect%s%s, timeout=%d\n", rfds ? " read" : "",
+ wfds ? " write" : rfds ? "" : " (none)", timeout);
alarm(2);
nready = select(maxfd + 1, rfds, wfds, NULL, &tv);
0 fd(s) ready
poll POLLOUT, timeout=0
1 fd(s) ready, revents == POLLOUT
+ poll (none), timeout=0
+ 0 fd(s) ready
select read write
1 fd(s) ready, writeable
select read
0 fd(s) ready
select write
1 fd(s) ready, writeable
+ select
+ 0 fd(s) ready
Testing full FIFO:
poll POLLIN|POLLOUT, timeout=0
1 fd(s) ready, revents == POLLIN
poll POLLOUT, timeout=0
1 fd(s) ready, revents == POLLOUT
+ poll (none), timeout=0
+ 0 fd(s) ready
select read write
2 fd(s) ready, readable, writeable
select read
1 fd(s) ready, readable
select write
1 fd(s) ready, writeable
+ select
+ 0 fd(s) ready
received 'test' from FIFO
Opened fifo fi.fo.fum
poll: Interrupted system call
poll POLLOUT, timeout=-1
1 fd(s) ready, revents == POLLOUT
+ poll (none), timeout=-1
+poll: Interrupted system call
select read write
1 fd(s) ready, writeable
select read
0 fd(s) ready
select write
1 fd(s) ready, writeable
+ select
+ 0 fd(s) ready
Testing full FIFO:
poll POLLIN|POLLOUT, timeout=-1
1 fd(s) ready, revents == POLLIN
poll POLLOUT, timeout=-1
1 fd(s) ready, revents == POLLOUT
+ poll (none), timeout=-1
+poll: Interrupted system call
select read write
2 fd(s) ready, readable, writeable
select read
1 fd(s) ready, readable
select write
1 fd(s) ready, writeable
+ select
+ 0 fd(s) ready
received 'test' from FIFO
Opened fifo fi.fo.fum (nonblocking)
0 fd(s) ready
poll POLLOUT, timeout=0
1 fd(s) ready, revents == POLLOUT
+ poll (none), timeout=0
+ 0 fd(s) ready
select read write
1 fd(s) ready, writeable
select read
0 fd(s) ready
select write
1 fd(s) ready, writeable
+ select
+ 0 fd(s) ready
Testing full FIFO:
poll POLLIN|POLLOUT, timeout=0
1 fd(s) ready, revents == POLLIN
poll POLLOUT, timeout=0
1 fd(s) ready, revents == POLLOUT
+ poll (none), timeout=0
+ 0 fd(s) ready
select read write
2 fd(s) ready, readable, writeable
select read
1 fd(s) ready, readable
select write
1 fd(s) ready, writeable
+ select
+ 0 fd(s) ready
received 'test' from FIFO
Opened fifo fi.fo.fum (nonblocking)
poll: Interrupted system call
poll POLLOUT, timeout=-1
1 fd(s) ready, revents == POLLOUT
+ poll (none), timeout=-1
+poll: Interrupted system call
select read write
1 fd(s) ready, writeable
select read
0 fd(s) ready
select write
1 fd(s) ready, writeable
+ select
+ 0 fd(s) ready
Testing full FIFO:
poll POLLIN|POLLOUT, timeout=-1
1 fd(s) ready, revents == POLLIN
poll POLLOUT, timeout=-1
1 fd(s) ready, revents == POLLOUT
+ poll (none), timeout=-1
+poll: Interrupted system call
select read write
2 fd(s) ready, readable, writeable
select read
1 fd(s) ready, readable
select write
1 fd(s) ready, writeable
+ select
+ 0 fd(s) ready
received 'test' from FIFO
Opened fifo for reading fi.fo.fum (nonblocking)
Testing EOF FIFO behavior (pass 1):
poll POLLIN|POLLOUT, timeout=-1
- 1 fd(s) ready, revents == POLLOUT
+ 1 fd(s) ready, revents == POLLIN POLLHUP
received EOF from FIFO
Opened fifo for reading fi.fo.fum (nonblocking)
Opened fifo for reading fi.fo.fum (nonblocking)
Testing EOF FIFO behavior (pass 6):
+ poll (none), timeout=-1
+poll: Interrupted system call
+ received EOF from FIFO
+
+Testing EOF FIFO behavior (pass 7):
+ poll (none), timeout=-1
+poll: Interrupted system call
+ received EOF from FIFO
+
+Opened fifo for reading fi.fo.fum (nonblocking)
+
+Testing EOF FIFO behavior (pass 8):
select read write
1 fd(s) ready, writeable
received EOF from FIFO
-Testing EOF FIFO behavior (pass 7):
+Testing EOF FIFO behavior (pass 9):
select read write
1 fd(s) ready, writeable
received EOF from FIFO
Opened fifo for reading fi.fo.fum (nonblocking)
-Testing EOF FIFO behavior (pass 8):
+Testing EOF FIFO behavior (pass 10):
select read
0 fd(s) ready
received EOF from FIFO
-Testing EOF FIFO behavior (pass 9):
+Testing EOF FIFO behavior (pass 11):
select read
- 0 fd(s) ready
+ 1 fd(s) ready, readable
received EOF from FIFO
Opened fifo for reading fi.fo.fum (nonblocking)
-Testing EOF FIFO behavior (pass 10):
+Testing EOF FIFO behavior (pass 12):
select write
1 fd(s) ready, writeable
received EOF from FIFO
-Testing EOF FIFO behavior (pass 11):
+Testing EOF FIFO behavior (pass 13):
select write
1 fd(s) ready, writeable
received EOF from FIFO
+
+Opened fifo for reading fi.fo.fum (nonblocking)
+
+Testing EOF FIFO behavior (pass 14):
+ select
+ 0 fd(s) ready
+ received EOF from FIFO
+
+Testing EOF FIFO behavior (pass 15):
+ select
+ 0 fd(s) ready
+ received EOF from FIFO