#include #include #include #include #include int main() { WINDOW *w; fd_set fds; int maxfd; int mousefd, fifo; int c; w = initscr(); cbreak(); keypad(w, TRUE); mousemask(ALL_MOUSE_EVENTS, NULL); noecho(); intrflush(stdscr, FALSE); clear(); refresh(); mousefd = getmousefd(); fifo = open("fifo", O_RDONLY | O_NONBLOCK); FD_ZERO(&fds); maxfd = 0; FD_SET(STDIN_FILENO, &fds); maxfd = STDIN_FILENO > maxfd ? STDIN_FILENO : maxfd; if (mousefd >= 0) { FD_SET(mousefd, &fds); maxfd = mousefd > maxfd ? mousefd : maxfd; } if (fifo >= 0) { FD_SET(fifo, &fds); maxfd = fifo > maxfd ? fifo : maxfd; } printf("waiting for an event to arrive\r\n"); select(maxfd + 1, &fds, NULL, NULL, NULL); clear(); refresh(); endwin(); printf("stdin: %d\n", FD_ISSET(STDIN_FILENO, &fds)); printf("mousefd: %d\n", FD_ISSET(mousefd, &fds)); printf("fifo: %d\n", FD_ISSET(fifo, &fds)); printf("event arrived, exiting\n"); return EXIT_SUCCESS; }