6 * fdpass - routines to pass a file descriptor over a socket.
8 * This code handles all the hairy details of fd passing.
10 * License: CC0 (Public domain)
11 * Maintainer: Rusty Russell <rusty@rustcorp.com.au>
15 * #include <ccan/fdpass/fdpass.h>
16 * #include <sys/socket.h>
22 * static void child(int sockfd)
25 * int newfd = fdpass_recv(sockfd);
26 * read(newfd, buffer, sizeof(buffer));
27 * printf("%.*s\n", (int)sizeof(buffer), buffer);
31 * static void parent(int sockfd)
36 * fdpass_send(sockfd, pfds[0]);
38 * write(pfds[1], "hello!", 6);
46 * socketpair(AF_UNIX, SOCK_STREAM, 0, sv);
53 int main(int argc, char *argv[])
55 /* Expect exactly one argument */
59 if (strcmp(argv[1], "depends") == 0)