To pass a file descriptor you need to AF_UNIX sockets, not named pipes. You'll need sendmsg(3), which is insanely weird to use, so you'd better look up some example on the web -- eg io_passfd in libowfat.
Edit: in case anyone stumbles upon this answer, don't use an AF_UNIX client/server, use socketpair(2)