#include #include #include int main() { int p1[2]; int p2[2]; pipe(p1); pipe(p2); if (fork()) { struct pollfd fds[2]; fds[0].fd = p1[0]; fds[0].events = POLLIN; fds[1].fd = p2[0]; fds[1].events = POLLIN; poll(fds, 2, -1); if (fds[0].revents & POLLIN) printf("First!\n"); if (fds[1].revents & POLLIN) printf("Second!\n"); } else if (fork()) { sleep(5); char one = 1; write(p1[1], &one, 1); } else { sleep(3); char one = 1; write(p2[1], &one, 1); } }