Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sharvil/flingfd
A tiny library to send file descriptors across processes
https://github.com/sharvil/flingfd
c descriptor file linux
Last synced: 3 months ago
JSON representation
A tiny library to send file descriptors across processes
- Host: GitHub
- URL: https://github.com/sharvil/flingfd
- Owner: sharvil
- License: other
- Created: 2013-12-21T07:09:47.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-11-25T18:38:40.000Z (almost 7 years ago)
- Last Synced: 2024-05-28T12:51:41.767Z (5 months ago)
- Topics: c, descriptor, file, linux
- Language: C
- Size: 7.81 KB
- Stars: 167
- Watchers: 12
- Forks: 15
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flingfd
flingfd is a small, standalone C library to pass file descriptors across processes on Linux.## Installation
By default, flingfd installs in `/usr/local`. If you want to change where it gets installed, edit the `PREFIX` in the Makefile.```
$ make && sudo make install
```## Documentation
The library consists of two functions declared in `flingfd.h`:
```c
bool flingfd_simple_send(const char *path, int fd);
int flingfd_simple_recv(const char *path);
```When you want to send a file descriptor, call `flingfd_simple_send` and receive it in the other process with `flingfd_simple_recv`. Make sure you use the same `path` argument in both processes -- that determines which process gets the file descriptor.
Here's an example of sending `stdout` to another process:
```c
#includevoid send_my_stdout() {
int fd = fileno(stdout);
flingfd_simple_send("/tmp/some_unique_path", fd);
}
```And here's the other process writing to the sender's `stdout`:
```c
#includevoid write_to_their_stdout() {
int fd = 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`.
## Bindings
* Python - https://github.com/soulseekah/pyflingfd
## License
Apache 2.0