%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
#include <assert.h> #include <poll.h> #include <time.h> #include <unistd.h> #include <stdlib.h> #include <string.h> int main(void) { struct pollfd fds[4]; time_t before, now; int ret; char* platform; int is_aix; int is_win; platform = getenv("NODE_PLATFORM"); is_aix = platform != NULL && 0 == strcmp(platform, "aix"); is_win = platform != NULL && 0 == strcmp(platform, "win32"); // Test sleep() behavior. time(&before); sleep(1); time(&now); assert(now - before >= 1); // Test poll() timeout behavior. fds[0] = (struct pollfd){.fd = -1, .events = 0, .revents = 0}; time(&before); ret = poll(fds, 1, 2000); time(&now); assert(ret == 0); assert(now - before >= 2); // The rest of the test is unsupported on Windows. if (is_win) return 0; fds[0] = (struct pollfd){.fd = 1, .events = POLLOUT, .revents = 0}; fds[1] = (struct pollfd){.fd = 2, .events = POLLOUT, .revents = 0}; ret = poll(fds, 2, -1); assert(ret == 2); assert(fds[0].revents == POLLOUT); assert(fds[1].revents == POLLOUT); // Make a poll() call with duplicate file descriptors. fds[0] = (struct pollfd){.fd = 1, .events = POLLOUT, .revents = 0}; fds[1] = (struct pollfd){.fd = 2, .events = POLLOUT, .revents = 0}; fds[2] = (struct pollfd){.fd = 1, .events = POLLOUT, .revents = 0}; fds[3] = (struct pollfd){.fd = 1, .events = POLLIN, .revents = 0}; ret = poll(fds, 2, -1); assert(ret == 2); assert(fds[0].revents == POLLOUT); assert(fds[1].revents == POLLOUT); assert(fds[2].revents == 0); assert(fds[3].revents == 0); // The original version of this test expected a timeout and return value of // zero. In the Node test suite, STDIN is not a TTY, and poll() returns one, // with revents = POLLHUP | POLLIN, except on AIX whose poll() does not // support POLLHUP. fds[0] = (struct pollfd){.fd = 0, .events = POLLIN, .revents = 0}; ret = poll(fds, 1, 2000); assert(ret == 1); if (is_aix) assert(fds[0].revents == POLLIN); else assert(fds[0].revents == (POLLHUP | POLLIN)); return 0; }