flingfd is a small, standalone C library to pass file descriptors across processes on Linux.
By default, flingfd installs in/usr/local
. If you want to change where it gets installed, edit thePREFIX
in the Makefile.
$ make && sudo make install
The library consists of two functions declared inflingfd.h
:
boolflingfd_simple_send(constchar*path,intfd);intflingfd_simple_recv(constchar*path);
When you want to send a file descriptor, callflingfd_simple_send
and receive it in the other process withflingfd_simple_recv
. Make sure you use the samepath
argument in both processes -- that determines which process gets the file descriptor.
Here's an example of sendingstdout
to another process:
#include<flingfd.h>voidsend_my_stdout() {intfd=fileno(stdout);flingfd_simple_send("/tmp/some_unique_path",fd); }
And here's the other process writing to the sender'sstdout
:
#include<flingfd.h>voidwrite_to_their_stdout() {intfd=flingfd_simple_recv("/tmp/some_unique_path");write(fd,"Hello world\n",12); }
When you're done writing your code, link against the library with-lflingfd
.
Apache 2.0