Git Product home page Git Product logo

splicepipe's Introduction

splicepipe

sender -> splicepipe -> receiver

usage

pass in the input and output fifo paths. the fifos will be creates for you.

splicepipe /path/to/input/fifo /path/to/output/fifo

why

i wanted to plot some data in a tool.

the plotting tool i'm using renders the plots in a web page. this is nice, since it lets me open the plots on my laptop. however restarting the plotter requires refreshing the page.

this can be fixed with a fifo. i can point my tool at the fifo to write, read the fifo into the plotter.

# make fifo
mkfifo /tmp/fifo

# start the plotter, reading in from the fifo, forking to background
wesplot < /tmp/fifo &

# run tool, redirecting stdout to the fifo
mytool > /tmp/fifo

however when the peer of the fifo closes the file, it closes for both sides. directing the data into the plotter this way means it wont be reopened, so the plotter needs to be restarted.

directing an empty descriptor can prevent the reader from closing. as long as there is at least one writer, the fifo will remain open.

# point unused descriptor at fifo to keep it open, forking to the background
3>/tmp/fifo &

to get around this we can write a tool that reads the fifo, piping the data to the plotter, and reopening the fifo whenever it closes.

# run the fifo reader, piping the output into the plotter, forking to background
fiforeader /tmp/fifo | wesplot &

we have the same problem in the other direction. when the reader closes the fifo, the writer is closed too. having to restart the tool any time i want to make changes to the plotter is also undesirable.

to fix this we can make a similar fifowriter. we could also make a fifo coupling. two separate fifos, read and written to by a middle program, which continues running and reopens the fifo handles any time a writer or reader closes.

# run the fifo coupler, forking to background
splicepipe /tmp/input /tmp/output &

# run the plotter, reading in from the output fifo, forking to background
wesplot < /tmp/output &

run the tool, writing to the output fifo
mytool > /tmp/intput

i also needed to add a domain column to the data. due to how the plotter functions, i cannot add it to my tool, since the tool would reset to zero each time. this would produce bad plots. to fix this, the domain, which is just the line number, is added in the coupler. this way when the writer restarts, the plotter doesn't see that they started over.

splicepipe's People

Contributors

noriah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.