void child_process(int sock) { int fd; int fds[2], nfds; char b[] = "This is on the received fd!\n"; if(ancil_recv_fd(sock, &fd)) { perror("ancil_recv_fd"); exit(1); } else { printf("Received fd: %d\n", fd); } write(fd, b, sizeof(b)); close(fd); sleep(2); nfds = ancil_recv_fds(sock, fds, 2); if(nfds < 0) { perror("ancil_recv_fds"); exit(1); } else { printf("Received %d/2 fds : %d %d.\n", nfds, fds[0], fds[1]); } }
int timed_ancil_fds_recv (int fdsocket, int *fds, unsigned int n, struct taia const *deadline, struct taia *stamp) { iopause_fd x = { fdsocket, IOPAUSE_READ, 0 } ; for (;;) { register int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_READ) { r = sanitize_read(ancil_recv_fds(fdsocket, fds, n)) ; if (r < 0) return 0 ; else if (r > 0) break ; } } return 1 ; }