https://github.com/begriffs/ringfifo
Nonblocking multi-use named pipes
https://github.com/begriffs/ringfifo
Last synced: about 1 year ago
JSON representation
Nonblocking multi-use named pipes
- Host: GitHub
- URL: https://github.com/begriffs/ringfifo
- Owner: begriffs
- License: isc
- Created: 2021-12-23T21:53:11.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-23T21:53:30.000Z (about 4 years ago)
- Last Synced: 2025-01-10T17:50:14.041Z (about 1 year ago)
- Language: C
- Size: 1.95 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Nonblocking multi-use named pipes
Ringfifo manages two named pipes to create a virtual fifo. As long as the
program is running, writers are never blocked, and readers never get an EOF.
```sh
# create foo.in, foo.out and wait for data
$ ringfifo foo &
# echo returns right away
$ echo hi > foo.in
# empties buffer, waits for more
$ cat foo.out
hi
```
In that example, you can pipe more data to `foo.in` and `cat` will continue to
print it. If you terminate `cat`, then `ringfifo` will again queue incoming
lines for later.
The program has a configurable internal line limit, at which point it'll drop
old lines from the buffer to make room for new lines.
### Usage
```
ringfifo fifo-name [max-lines]
```
* `fifo-name` base name of the virtual fifo. Creates named pipes `fifo-name.in`
and `fifo-name.out`.
* `max-lines` line limit of the internal ring buffer. Default 8192.
Each buffered line is currently limited to `BUFSIZ` characters. I haven't taken
the time to make that configurable, but it's an easy change.
### Building
Requires POSIX and [libderp](https://github.com/begriffs/libderp) 0.1.0.
Install libderp, and run `make`. The library will be statically linked into the
executable.