Introductory concepts poll() IO Pass a set of FDs to check for various IO states read, write, error, HUP, OOB struct pollfds pfds[3]; int readyfds; int timeout = 3; /* milliseconds */ bzero(&pfds, sizeof(pfds)); pfds[0].events = POLLRDNORM; pfds[1].events = POLLWRNORM; pfds[2].events = POLLWRNORM; readyfds = poll(&pfds, 3, timeout); if (pfds[0].revents | POLLRDNORM) { /* Handle STDIN ready */ } if (pfds[1].revents | POLLWRNORM) { /* Handle STDOUT ready */ } if (pfds[2].revents | POLLWRNORM) { /* Handle STDERR read */ }